﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using 货物监控;




namespace 货物监控
{
    public partial class NetForm : Form
    {
        public static NetForm _This = null;

        string CurrentDirectory;
        public NetForm()
        {
            /*获取应用程序的当前工作目录。*/
            CurrentDirectory = Directory.GetCurrentDirectory();
            InitializeComponent();

            _This = this;
        }




        public static int getErrorInformation(int error_code, out string message)
        {
            int result = 0;
            byte[] errorInfo = new byte[1024];
            PrintLab.PTK_GetErrorInfo(error_code, errorInfo, errorInfo.Length);
            message = Encoding.Default.GetString(errorInfo).Trim('\0');
            return result;
        }


        private static void showError(string FunctionName, int error_code)
        {
            PrintLab.PTK_CloseConnect();
            var message = "";
            int result = getErrorInformation(error_code, out message);
            MessageBox.Show(FunctionName + ":" + message);
        }


        /*设置打印机IP地址*/
        /*打印之前先确保打印机已配置到你所处的局域网内，可用ping命令检测打印机是否已经在局域网内
         *打印机IP地址可以打印自检页查看，也可以在Utility或者液晶屏中查看
         * 配置打印机的IP地址和端口号：可在打印机液晶屏或者Utility中配置
         * 端口一般不用配置，用默认值9100就好
         */
        public static string IPAddress = "10.95.16.62";
        public static uint port = 9100;
        public static byte[] E_UTF8(String data)
        {
            return Encoding.UTF8.GetBytes(data);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            /*
            *mm:点，毫米转为点，由打印机分辨率决定
            * 打印机分辨DPI=203时， mm=8
            * 打印机分辨DPI=300时， mm=12
            * 打印机分辨DPI=600时， mm=24
            */
            uint mm = 12;

            int result = 0;
            var message = "";

            /*连接打印机*/
            result = PrintLab.PTK_Connect_Timer(IPAddress, port, 5);
            if (result != 0)
            {
                result = getErrorInformation(result, out message);
                MessageBox.Show(message);
                return;
            }

            /*函数返回值*/
            int result_printing = 0;
            /*横坐标偏移,设置标签整体横向移动位置*/
            int offset_X = 0;

            /*纵坐标偏移，设置标签整体纵向移动位置*/
            int offset_Y = 0;


            /*获取打印机状态*/
            int[] status_Net = new int[4];
            String PrinterStatus = "";
            result_printing = PrintLab.PTK_FeedBack();
            if (result_printing != 0) { showError("PTK_FeedBack", result_printing); return; }

            result_printing = PrintLab.PTK_ReadData(status_Net, 4);
            if (result_printing != 0) { showError("PTK_ReadData", result_printing); return; }

            PrinterStatus = status_Net[0] + "";

            if (!PrinterStatus.Equals("0") && !PrinterStatus.Equals("4"))
            {
                PrintLab.PTK_CloseConnect();
                MessageBox.Show("打印机未就绪，当前错误报告：" + Status_Explain(PrinterStatus));

                return;
            }

            /*OX平台获取打印机状态*/
            byte[] status_Net_OX = new byte[128];
            result_printing = PrintLab.PTK_GetPrinterStatus_Net_OX(status_Net_OX);
            if (result_printing != 0)
            {
                showError("PTK_GetPrinterStatus_Net", result_printing);
                return;
            }
            string statusCode = Encoding.UTF8.GetString(status_Net_OX).TrimEnd('\0');
            // 在消息框中显示打印机状态
            MessageBox.Show("打印机状态：" + Status_Explain(statusCode));



            /*清空缓存*/
            result_printing = PrintLab.PTK_ClearBuffer();
            if (result_printing != 0) { showError("PTK_ClearBuffer", result_printing); return; }

            /*设置打印黑度 取值范围 0-20*/
            result_printing = PrintLab.PTK_SetDarkness(10);
            if (result_printing != 0) { showError("PTK_SetDarkness", result_printing); return; }

            /*设置打印速度*/
            result_printing = PrintLab.PTK_SetPrintSpeed(4);
            if (result_printing != 0) { showError("PTK_SetPrintSpeed", result_printing); return; }

            /*设置打印方向*/
            result_printing = PrintLab.PTK_SetDirection('B');
            if (result_printing != 0) { showError("PTK_SetDirection", result_printing); return; }

            /*设置标签高度、间隙及偏移*/
            result_printing = PrintLab.PTK_SetLabelHeight(75 * mm, 24, 0, false);
            if (result_printing != 0) { showError("PTK_SetLabelHeight", result_printing); return; }

            /*设置标签宽度，一定要准确，否则会导致打印内容位置不准确*/
            result_printing = PrintLab.PTK_SetLabelWidth(104 * mm);
            if (result_printing != 0) { showError("PTK_SetLabelWidth", result_printing); return; }

            /* 打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(80 + offset_X), (uint)(180 + offset_Y), 4 * mm, 0, E_UTF8("微软雅黑"), 1, 400, false, false, false, E_UTF8("博思得科技发展有限公司"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印本地图片*/
            result_printing = PrintLab.PTK_AnyGraphicsPrint((uint)(20 + offset_X), (uint)(20 + offset_Y), "picture", "D:/logo.png", 1, 0, 0, 0);
            if (result_printing != 0) { showError("PTK_AnyGraphicsPrint", result_printing); return; }

            /*打印，必须要执行这一行，否则不会打印，打印多张标签时每张标签后面都需要加它*/
            result_printing = PrintLab.PTK_PrintLabel(1, 1);
            if (result_printing != 0) { showError("PTK_PrintLabel", result_printing); return; }


            /*断开打印机连接*/
            PrintLab.PTK_CloseConnect();


            MessageBox.Show("执行成功！");
        }


        public static void printText()
        {

            uint mm = 12;

            int result = 0;
            var message = "";

            /*连接打印机*/
            result = PrintLab.PTK_Connect_Timer(IPAddress, port, 5);
            if (result != 0)
            {
                result = getErrorInformation(result, out message);
                MessageBox.Show(message);
                return;
            }

            /*函数返回值*/
            int result_printing = 0;
            /*横坐标偏移,设置标签整体横向移动位置*/
            int offset_X = 0;

            /*纵坐标偏移，设置标签整体纵向移动位置*/
            int offset_Y = 0;


            /*获取打印机状态*/
            int[] status_Net = new int[4];
            String PrinterStatus = "";
            result_printing = PrintLab.PTK_FeedBack();
            if (result_printing != 0) { showError("PTK_FeedBack", result_printing); return; }

            //result_printing = PrintLab.PTK_ReadData(status_Net, 4);
            //if (result_printing != 0) { showError("PTK_ReadData", result_printing); return; }

            //PrinterStatus = status_Net[0] + "";

            //if (!PrinterStatus.Equals("0") && !PrinterStatus.Equals("4"))
            //{
            //    PrintLab.PTK_CloseConnect();
            //    MessageBox.Show("打印机未就绪，当前错误报告：" + Status_Explain(PrinterStatus));

            //    return;
            //}

            /*OX平台获取打印机状态*/
            byte[] status_Net_OX = new byte[128];
            result_printing = PrintLab.PTK_GetPrinterStatus_Net_OX(status_Net_OX);
            if (result_printing != 0)
            {
                showError("PTK_GetPrinterStatus_Net", result_printing);
                return;
            }
            string statusCode = Encoding.UTF8.GetString(status_Net_OX).TrimEnd('\0');
            // 在消息框中显示打印机状态
            MessageBox.Show("打印机状态：" + Status_Explain(statusCode));



            /*清空缓存*/
            result_printing = PrintLab.PTK_ClearBuffer();
            if (result_printing != 0) { showError("PTK_ClearBuffer", result_printing); return; }

            /*设置打印黑度 取值范围 0-20*/
            result_printing = PrintLab.PTK_SetDarkness(10);
            if (result_printing != 0) { showError("PTK_SetDarkness", result_printing); return; }

            /*设置打印速度*/
            result_printing = PrintLab.PTK_SetPrintSpeed(4);
            if (result_printing != 0) { showError("PTK_SetPrintSpeed", result_printing); return; }

            /*设置打印方向*/
            result_printing = PrintLab.PTK_SetDirection('B');
            if (result_printing != 0) { showError("PTK_SetDirection", result_printing); return; }

            /*设置标签高度、间隙及偏移*/
            result_printing = PrintLab.PTK_SetLabelHeight(75 * mm, 24, 0, false);
            if (result_printing != 0) { showError("PTK_SetLabelHeight", result_printing); return; }

            /*设置标签宽度，一定要准确，否则会导致打印内容位置不准确*/
            result_printing = PrintLab.PTK_SetLabelWidth(104 * mm);
            if (result_printing != 0) { showError("PTK_SetLabelWidth", result_printing); return; }

            /* 打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(80 + offset_X), (uint)(180 + offset_Y), 4 * mm, 0, E_UTF8("微软雅黑"), 1, 400, false, false, false, E_UTF8("博思得科技发展有限公司"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }



            /*打印，必须要执行这一行，否则不会打印，打印多张标签时每张标签后面都需要加它*/
            result_printing = PrintLab.PTK_PrintLabel(1, 1);
            if (result_printing != 0) { showError("PTK_PrintLabel", result_printing); return; }


            /*断开打印机连接*/
            PrintLab.PTK_CloseConnect();

            MessageBox.Show("执行成功！");
        }



        private void PrintOneLabel_Click(object sender, EventArgs e)
        {
            /*
             *mm:点，毫米转为点，由打印机分辨率决定
             * 打印机分辨DPI=203时， mm=8
             * 打印机分辨DPI=300时， mm=12
             * 打印机分辨DPI=600时， mm=24
             */
            uint mm = 12;

            int result = 0;
            var message = "";

            /*连接打印机*/
            result = PrintLab.PTK_Connect_Timer(IPAddress, port, 2);
            if (result != 0)
            {
                result = getErrorInformation(result, out message);
                MessageBox.Show(message);
                return;
            }

            /*函数返回值*/
            int result_printing = 0;

            /*横坐标偏移,设置标签整体横向移动位置*/
            int offset_X = 0;

            /*纵坐标偏移，设置标签整体纵向移动位置*/
            int offset_Y = 0;

            /*清空缓存*/
            result_printing = PrintLab.PTK_ClearBuffer();
            if (result_printing != 0) { showError("PTK_ClearBuffer", result_printing); return; }

            /*设置打印黑度 取值范围 0-20*/
            result_printing = PrintLab.PTK_SetDarkness(10);
            if (result_printing != 0) { showError("PTK_SetDarkness", result_printing); return; }

            /*设置打印速度*/
            result_printing = PrintLab.PTK_SetPrintSpeed(4);
            if (result_printing != 0) { showError("PTK_SetPrintSpeed", result_printing); return; }

            /*设置打印方向*/
            result_printing = PrintLab.PTK_SetDirection('B');
            if (result_printing != 0) { showError("PTK_SetDirection", result_printing); return; }

            /*设置标签高度、间隙及偏移*/
            result_printing = PrintLab.PTK_SetLabelHeight(30 * mm, 24, 0, false);
            if (result_printing != 0) { showError("PTK_SetLabelHeight", result_printing); return; }

            /*设置标签宽度，一定要准确，否则会导致打印内容位置不准确*/
            result_printing = PrintLab.PTK_SetLabelWidth(50 * mm);
            if (result_printing != 0) { showError("PTK_SetLabelWidth", result_printing); return; }

            /*打印矩形*/
            result_printing = PrintLab.PTK_DrawRectangle((uint)(18 + offset_X), (uint)(12 + offset_Y), 4, 585, 343);
            if (result_printing != 0) { showError("PTK_DrawRectangle", result_printing); return; }

            /*打印一维码 此示例为Code128码*/
            result_printing = PrintLab.PTK_DrawBarcode((uint)(30 + offset_X), (uint)(99 + offset_Y), 0, "1", 2, 6, 40, 'N', E_UTF8("12345678"));//打印一维码
            if (result_printing != 0) { showError("PTK_DrawBarcode", result_printing); return; }

            /* 打印条码下方文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(30 + offset_X), (uint)(99 + 40 + 4 + offset_Y), 2 * mm, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("12345678"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印本地图片*/
            result_printing = PrintLab.PTK_AnyGraphicsPrint((uint)(413 + offset_X), (uint)(135 + offset_Y), "picture", CurrentDirectory + "\\logo\\logo.jpg", 0.6f, 0, 0, 0);
            if (result_printing != 0) { showError("PTK_AnyGraphicsPrint", result_printing); return; }

            /*打印网络图片*/
            //result_printing = PrintLab.PTK_AnyGraphicsPrint((uint)(413 + offset_X), (uint)(135 + offset_Y), "logo", "https://www.postek.com.cn/print/logo.png", 0.6f, 92, 74, 0);
            //if (result_printing != 0) { showError("PTK_AnyGraphicsPrint", result_printing); return; }

            /*打印一维码 此示例为UPC码*/
            result_printing = PrintLab.PTK_DrawBarcode((uint)(213 + offset_X), (uint)(98 + offset_Y), 0, "UE0", 2, 6, 47, 'N', E_UTF8("234567"));
            if (result_printing != 0) { showError("PTK_DrawBarcode", result_printing); return; }

            /* 打印条码下方文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(213 + offset_X), (uint)(98 + 47 + 4 + offset_Y), 2 * mm, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("12345678"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印二维码 此示例为QR码 付款码就是这个码*/
            result_printing = PrintLab.PTK_DrawBar2D_QR((uint)(30 + offset_X), (uint)(182 + offset_Y), 0, 0, 0, 3, 4, 1, 8, E_UTF8("设计精湛 ABCD 1234 ^-^ @@ && $$ ￥￥"));
            if (result_printing != 0) { showError("PTK_DrawBar2D_QR", result_printing); return; }

            /*打印二维码 此示例为datamatrix码*/
            result_printing = PrintLab.PTK_DrawBar2D_DATAMATRIX((uint)(272 + offset_X), (uint)(182 + offset_Y), 0, 0, 0, 5, E_UTF8("设计精湛 ABCD 1234 ^-^ @@ && $$ ￥￥"));
            if (result_printing != 0) { showError("PTK_DrawBar2D_DATAMATRIX", result_printing); return; }

            /*打印二维码 此示例为PDF417码*/
            result_printing = PrintLab.PTK_DrawBar2D_Pdf417((uint)(25 + offset_X), (uint)(288 + offset_Y), 240, 38, 3, 0, 2, 2, 10, 6, 0, 0, E_UTF8("设计精湛 ABCD 1234 ^-^ @@ && $$ ￥￥"));
            if (result_printing != 0) { showError("PTK_DrawBar2D_Pdf417", result_printing); return; }

            /*打印二维码 此示例为汉信码*/
            result_printing = PrintLab.PTK_DrawBar2D_HANXIN((uint)(155 + offset_X), (uint)(182 + offset_Y), 0, 0, 0, 3, 3, 0, 0, E_UTF8("设计精湛 ABCD 1234 ^-^ @@ && $$ ￥￥"));
            if (result_printing != 0) { showError("PTK_DrawBar2D_HANXIN", result_printing); return; }

            /*打印斜线*/
            result_printing = PrintLab.PTK_DrawDiagonal((uint)(374 + offset_X), (uint)(343 + offset_Y), 4, 478, 222);
            if (result_printing != 0) { showError("PTK_DrawDiagonal", result_printing); return; }

            /*打印斜线*/
            result_printing = PrintLab.PTK_DrawDiagonal((uint)(478 + offset_X), (uint)(222 + offset_Y), 4, 585, 343);
            if (result_printing != 0) { showError("PTK_DrawDiagonal", result_printing); return; }

            /*打印直线*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(20 + offset_X), (uint)(90 + offset_Y), 562, 4);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /*打印直线*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(374 + offset_X), (uint)(90 + offset_Y), 4, 252);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /* 打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(112 + offset_X), (uint)(21 + offset_Y), 28, 0, E_UTF8("华文行楷"), 1, 400, false, false, false, E_UTF8("深圳市博思得科技发展有限公司"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /* 打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(125 + offset_X), (uint)(53 + offset_Y), 23, 0, E_UTF8("Magneto"), 1, 400, false, false, false, E_UTF8("Postek Electronics Co., Ltd."));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印，必须要执行这一行，否则不会打印，打印多张标签时每张标签后面都需要加它*/
            result_printing = PrintLab.PTK_PrintLabel(1, 1);
            if (result_printing != 0) { showError("PTK_PrintLabel", result_printing); return; }



            /*断开打印机连接*/
            PrintLab.PTK_CloseConnect();
            MessageBox.Show("执行成功！");



        }

        private void PrintBarcode_Click(object sender, EventArgs e)
        {
            /*
            *mm:点，毫米转为点，由打印机分辨率决定
            * 打印机分辨DPI=203时， mm=8
            * 打印机分辨DPI=300时， mm=12
            * 打印机分辨DPI=600时， mm=24
            */
            uint mm = 12;

            int result = 0;
            var message = "";

            /*连接打印机*/
            result = PrintLab.PTK_Connect_Timer(IPAddress, port, 2);
            if (result != 0)
            {
                result = getErrorInformation(result, out message);
                MessageBox.Show(message);
                return;
            }

            /*函数返回值*/
            int result_printing = 0;
            /*横坐标偏移,设置标签整体横向移动位置*/
            int offset_X = 0;

            /*纵坐标偏移，设置标签整体纵向移动位置*/
            int offset_Y = 0;

            /*获取打印机状态*/
            int[] status_Net = new int[4];
            String PrinterStatus = "";
            result_printing = PrintLab.PTK_FeedBack();
            if (result_printing != 0) { showError("PTK_FeedBack", result_printing); return; }

            result_printing = PrintLab.PTK_ReadData(status_Net, 4);
            if (result_printing != 0) { showError("PTK_ReadData", result_printing); return; }

            PrinterStatus = status_Net[0] + "";

            if (!PrinterStatus.Equals("0") && !PrinterStatus.Equals("4"))
            {
                PrintLab.PTK_CloseConnect();
                MessageBox.Show("打印机未就绪，当前错误报告：" + Status_Explain(PrinterStatus));

                return;
            }


            /*清空缓存*/
            result_printing = PrintLab.PTK_ClearBuffer();
            if (result_printing != 0) { showError("PTK_ClearBuffer", result_printing); return; }

            /*设置打印黑度 取值范围 0-20*/
            result_printing = PrintLab.PTK_SetDarkness(10);
            if (result_printing != 0) { showError("PTK_SetDarkness", result_printing); return; }

            /*设置打印速度*/
            result_printing = PrintLab.PTK_SetPrintSpeed(4);
            if (result_printing != 0) { showError("PTK_SetPrintSpeed", result_printing); return; }

            /*设置打印方向*/
            result_printing = PrintLab.PTK_SetDirection('B');
            if (result_printing != 0) { showError("PTK_SetDirection", result_printing); return; }

            /*设置标签高度、间隙及偏移*/
            result_printing = PrintLab.PTK_SetLabelHeight(75 * mm, 24, 0, false);
            if (result_printing != 0) { showError("PTK_SetLabelHeight", result_printing); return; }

            /*设置标签宽度，一定要准确，否则会导致打印内容位置不准确*/
            result_printing = PrintLab.PTK_SetLabelWidth(104 * mm);
            if (result_printing != 0) { showError("PTK_SetLabelWidth", result_printing); return; }

            /* 打印条码*/
            result_printing = PrintLab.PTK_DrawBarcode((uint)(40 + offset_X), (uint)(40 + offset_Y), 0, "1", 2, 2, 4 * mm, 'N', E_UTF8("123456789"));
            if (result_printing != 0) { showError("PTK_DrawBarcode", result_printing); return; }

            /* 打印条码下方文字   20+4*mm+4为条码的Y坐标+条码高度+条码与文字间距*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(40 + offset_X), (uint)(40 + 4 * mm + 4 + offset_Y), 3 * mm, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("123456789"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }
            /*打印，必须要执行这一行，否则不会打印，打印多张标签时每张标签后面都需要加它*/
            result_printing = PrintLab.PTK_PrintLabel(1, 1);
            if (result_printing != 0) { showError("PTK_PrintLabel", result_printing); return; }



            /*断开打印机连接*/
            PrintLab.PTK_CloseConnect();


            MessageBox.Show("执行成功！");
        }

        private void PrintGraphics_Click(object sender, EventArgs e)
        {

            PrintImage("D:\\Print\\638617521460000236.png");
        }

        public static bool Conn(string IP)
        {

            IPAddress = IP;

            int result = 0;
            var message = "";

            /*连接打印机*/
            result = PrintLab.PTK_Connect_Timer(IPAddress, port, 2);
            if (result != 0)
            {
                result = getErrorInformation(result, out message);
                MessageBox.Show(message);
                return false;
            }
            else
            {

                return true;
            }
        }

        public static bool PrintImage(string imagepath)
        {

            /*
           *mm:点，毫米转为点，由打印机分辨率决定
           * 打印机分辨DPI=203时， mm=8
           * 打印机分辨DPI=300时， mm=12
           * 打印机分辨DPI=600时， mm=24
           */
            uint mm = 12;

            int result = 0;
            var message = "";

            /*连接打印机*/
            result = PrintLab.PTK_Connect_Timer(IPAddress, port, 2);
            if (result != 0)
            {
                result = getErrorInformation(result, out message);
                //MessageBox.Show(message);
                return false;
            }

            /*函数返回值*/
            int result_printing = 0;
            /*横坐标偏移,设置标签整体横向移动位置*/
            int offset_X = 0;

            /*纵坐标偏移，设置标签整体纵向移动位置*/
            int offset_Y = 0;



            /*OX平台获取打印机状态*/
            byte[] status_Net_OX = new byte[128];
            result_printing = PrintLab.PTK_GetPrinterStatus_Net_OX(status_Net_OX);
            if (result_printing != 0)
            {
                showError("PTK_GetPrinterStatus_Net", result_printing);
                return false;
            }
            string statusCode = Encoding.UTF8.GetString(status_Net_OX).TrimEnd('\0');
            // 在消息框中显示打印机状态
            //MessageBox.Show("打印机状态：" + Status_Explain(statusCode));


            /*清空缓存*/
            result_printing = PrintLab.PTK_ClearBuffer();
            if (result_printing != 0) { showError("PTK_ClearBuffer", result_printing); return false; }

            /*设置打印黑度 取值范围 0-20*/
            result_printing = PrintLab.PTK_SetDarkness(10);
            if (result_printing != 0) { showError("PTK_SetDarkness", result_printing); return false; }

            /*设置打印速度*/
            result_printing = PrintLab.PTK_SetPrintSpeed(4);
            if (result_printing != 0) { showError("PTK_SetPrintSpeed", result_printing); return false; }

            /*设置打印方向*/
            result_printing = PrintLab.PTK_SetDirection('B');
            if (result_printing != 0) { showError("PTK_SetDirection", result_printing); return false; }

            /*设置标签高度、间隙及偏移*/
            result_printing = PrintLab.PTK_SetLabelHeight(210 * mm, 24, 0, false);
            if (result_printing != 0) { showError("PTK_SetLabelHeight", result_printing); return false; }

            /*设置标签宽度，一定要准确，否则会导致打印内容位置不准确*/
            result_printing = PrintLab.PTK_SetLabelWidth(148 * mm);
            if (result_printing != 0) { showError("PTK_SetLabelWidth", result_printing); return false; }

            /*打印本地图片*/
            result_printing = PrintLab.PTK_AnyGraphicsPrint((uint)(50 + offset_X), (uint)(50 + offset_Y), "picture", imagepath, 0.62f, 0, 0, 3);
            if (result_printing != 0) { showError("PTK_AnyGraphicsPrint", result_printing); return false; }

            /*打印，必须要执行这一行，否则不会打印，打印多张标签时每张标签后面都需要加它*/
            result_printing = PrintLab.PTK_PrintLabel(1, 1);
            if (result_printing != 0) { showError("PTK_PrintLabel", result_printing); return false; }



            /*断开打印机连接*/
            PrintLab.PTK_CloseConnect();

            return true;

            //MessageBox.Show("执行成功！");
        }

        private void PrintGraphics_base64_Click(object sender, EventArgs e)
        {

            /*
            *mm:点，毫米转为点，由打印机分辨率决定
            * 打印机分辨DPI=203时， mm=8
            * 打印机分辨DPI=300时， mm=12
            * 打印机分辨DPI=600时， mm=24
            */
            uint mm = 12;

            int result = 0;
            var message = "";

            /*连接打印机*/
            result = PrintLab.PTK_Connect_Timer(IPAddress, port, 2);
            if (result != 0)
            {
                result = getErrorInformation(result, out message);
                MessageBox.Show(message);
                return;
            }

            /*函数返回值*/
            int result_printing = 0;
            /*横坐标偏移,设置标签整体横向移动位置*/
            int offset_X = 0;

            /*纵坐标偏移，设置标签整体纵向移动位置*/
            int offset_Y = 0;

            /*获取打印机状态*/
            int[] status_Net = new int[4];
            String PrinterStatus = "";
            result_printing = PrintLab.PTK_FeedBack();
            if (result_printing != 0) { showError("PTK_FeedBack", result_printing); return; }

            result_printing = PrintLab.PTK_ReadData(status_Net, 4);
            if (result_printing != 0) { showError("PTK_ReadData", result_printing); return; }

            PrinterStatus = status_Net[0] + "";

            if (!PrinterStatus.Equals("0") && !PrinterStatus.Equals("4"))
            {
                PrintLab.PTK_CloseConnect();
                MessageBox.Show("打印机未就绪，当前错误报告：" + Status_Explain(PrinterStatus));

                return;
            }


            /*清空缓存*/
            result_printing = PrintLab.PTK_ClearBuffer();
            if (result_printing != 0) { showError("PTK_ClearBuffer", result_printing); return; }

            /*设置打印黑度 取值范围 0-20*/
            result_printing = PrintLab.PTK_SetDarkness(10);
            if (result_printing != 0) { showError("PTK_SetDarkness", result_printing); return; }

            /*设置打印速度*/
            result_printing = PrintLab.PTK_SetPrintSpeed(4);
            if (result_printing != 0) { showError("PTK_SetPrintSpeed", result_printing); return; }

            /*设置打印方向*/
            result_printing = PrintLab.PTK_SetDirection('B');
            if (result_printing != 0) { showError("PTK_SetDirection", result_printing); return; }

            /*设置标签高度、间隙及偏移*/
            result_printing = PrintLab.PTK_SetLabelHeight(75 * mm, 24, 0, false);
            if (result_printing != 0) { showError("PTK_SetLabelHeight", result_printing); return; }

            /*设置标签宽度，一定要准确，否则会导致打印内容位置不准确*/
            result_printing = PrintLab.PTK_SetLabelWidth(104 * mm);
            if (result_printing != 0) { showError("PTK_SetLabelWidth", result_printing); return; }

            /* 打印图片(Base64)*/
            String Base64_Data = "iVBORw0KGgoAAAANSUhEUgAAAtEAAAKkCAYAAADGJmN1AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAAFiUAABYlAUlSJPAAAEttSURBVHhe7dbhbuVKji3hfv+XvheDg8ZMz0SRJouZpqT4gED/6OOV0i5L3v/6f5IkSZJK/BItSZIkFfklWpIkSSryS7QkSZJU5JdoSZIkqcgv0ZIkSVKRX6IlSZKkIr9ES5IkSUV+iZYkSZKK/BItSZIkFfklWpIkSSryS7QkSZJU5JdoSZIkqcgv0ZIkSVKRX6IlSZKkIr9ES5IkSUV+iZYkSZKK/BItSZIkFfklWpIkSSryS7QkSZJU5JdoSZIkqcgv0ZIkSVKRX6IlSZKkIr9ES5IkSUV+iZYkSZKK/BItSZ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REuSJElFfomWJEmSivwSLUmSJBX5JVqSJEkq8ku0JEmSVOSXaEmSJKnIL9GSJElSkV+iJUmSpCK/REuSJElFfomWJEmSivwSLUmSJBX5JVqSJEkq8ku0JEmSVOSXaEmSJKnIL9GSJElSkV+iJUmSpCK/REuSJElFfomWJEmSivwSLUmSJBX5JVqSJEkq8ku0JEmSVOSXaEmSJKnIL9GSJElSkV+iJUmSpCK/REuSJElFfomWJEmSivwSLUmSJBX5JVqSJEkq8ku0JEmSVOSXaEmSJKnIL9GSJElSkV+iJUmSpCK/REuSJElFfomWJEmSivwSLUmSJBX5JVqSJEkq8ku0JEmSVOSXaEmSJKnIL9GSJElSkV+iJUmSpCK/REuSJElFfomWJEmSivwSLUmSJBX5JVqSJEkq8ku0JEmSVOSXaEmSJKnIL9GSJElSkV+iJUmSpCK/REuSJElFfomWJEmSivwSLUmSJBX5JVqSJEkq8ku0JEmSVOSXaEmSJKnIL9GSJElSkV+iJUmSpCK/REuSJElFfomWJEmSivwSLUmSJBX5JVqSJEkq8ku0JEmSVOSXaEmSJKnIL9GSJElSkV+iJUmSpCK/REuSJElFfomWJEmSivwSLUmSJBX5JVqSJEkq8ku0JEmSVPL//t//B/vQz4oaUaBOAAAAAElFTkSuQmCC";
            result_printing = PrintLab.PTK_AnyGraphicsPrint_Base64((uint)(20 + offset_X), (uint)(20 + offset_Y), 4, 0.5f, 0, 0, 0, Base64_Data); ;

            if (result_printing != 0) { showError("PTK_AnyGraphicsPrint_Base64", result_printing); return; }

            /*打印，必须要执行这一行，否则不会打印，打印多张标签时每张标签后面都需要加它*/
            result_printing = PrintLab.PTK_PrintLabel(1, 1);
            if (result_printing != 0) { showError("PTK_PrintLabel", result_printing); return; }



            /*断开打印机连接*/
            PrintLab.PTK_CloseConnect();


            MessageBox.Show("执行成功！");
        }


        private void EncodeUHFRFID_Click(object sender, EventArgs e)
        {

            /*
            *mm:点，毫米转为点，由打印机分辨率决定
            * 打印机分辨DPI=203时， mm=8
            * 打印机分辨DPI=300时， mm=12
            * 打印机分辨DPI=600时， mm=24
            */
            uint mm = 12;

            int result = 0;
            var message = "";

            /*连接打印机*/
            result = PrintLab.PTK_Connect_Timer(IPAddress, port, 2);
            if (result != 0)
            {
                result = getErrorInformation(result, out message);
                MessageBox.Show(message);
                return;
            }

            /*函数返回值*/
            int result_printing = 0;
            /*横坐标偏移,设置标签整体横向移动位置*/
            int offset_X = 0;

            /*纵坐标偏移，设置标签整体纵向移动位置*/
            int offset_Y = 0;

            /*获取打印机状态*/
            int[] status_Net = new int[4];
            String PrinterStatus = "";
            result_printing = PrintLab.PTK_FeedBack();
            if (result_printing != 0) { showError("PTK_FeedBack", result_printing); return; }

            result_printing = PrintLab.PTK_ReadData(status_Net, 4);
            if (result_printing != 0) { showError("PTK_ReadData", result_printing); return; }

            PrinterStatus = status_Net[0] + "";

            if (!PrinterStatus.Equals("0") && !PrinterStatus.Equals("4"))
            {
                PrintLab.PTK_CloseConnect();
                MessageBox.Show("打印机未就绪，当前错误报告：" + Status_Explain(PrinterStatus));

                return;
            }


            /*清空缓存*/
            result_printing = PrintLab.PTK_ClearBuffer();
            if (result_printing != 0) { showError("PTK_ClearBuffer", result_printing); return; }

            /*设置打印黑度 取值范围 0-20*/
            result_printing = PrintLab.PTK_SetDarkness(10);
            if (result_printing != 0) { showError("PTK_SetDarkness", result_printing); return; }

            /*设置打印速度*/
            result_printing = PrintLab.PTK_SetPrintSpeed(4);
            if (result_printing != 0) { showError("PTK_SetPrintSpeed", result_printing); return; }

            /*设置打印方向*/
            result_printing = PrintLab.PTK_SetDirection('B');
            if (result_printing != 0) { showError("PTK_SetDirection", result_printing); return; }

            /*设置标签高度、间隙及偏移*/
            result_printing = PrintLab.PTK_SetLabelHeight(19 * mm, 24, 0, false);
            if (result_printing != 0) { showError("PTK_SetLabelHeight", result_printing); return; }

            /*设置标签宽度，一定要准确，否则会导致打印内容位置不准确*/
            result_printing = PrintLab.PTK_SetLabelWidth(80 * mm);
            if (result_printing != 0) { showError("PTK_SetLabelWidth", result_printing); return; }

            /*UHF RFID打印设置具体参数请查看API文档*/
            result_printing = PrintLab.PTK_SetRFID(0, 0, 0, 0, 0);
            if (result_printing != 0) { showError("PTK_SetRFID", result_printing); return; }

            /*写RFID数据 具体参数请查看API文档  *^-^*写数据之前确保RFID标签已经校准成功*/
            result_printing = PrintLab.PTK_RWRFIDLabel(1, 0, 2, 4, 1, "12345678");
            if (result_printing != 0) { showError("PTK_RWRFIDLabel", result_printing); return; }

            /* 打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(80 + offset_X), (uint)(60 + offset_Y), 4 * mm, 0, E_UTF8("宋体"), 1, 400, false, false, false, E_UTF8("博思得科技发展有限公司"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印，必须要执行这一行，否则不会打印，打印多张标签时每张标签后面都需要加它*/
            result_printing = PrintLab.PTK_PrintLabel(1, 1);
            if (result_printing != 0) { showError("PTK_PrintLabel", result_printing); return; }



            /*断开打印机连接*/
            PrintLab.PTK_CloseConnect();


            MessageBox.Show("执行成功！");
        }

        private void ReadUHFRFIDData_Click(object sender, EventArgs e)
        {
            int result = 0;
            var message = "";

            /*连接打印机*/
            result = PrintLab.PTK_Connect_Timer(IPAddress, port, 2);
            if (result != 0)
            {
                result = getErrorInformation(result, out message);
                MessageBox.Show(message);
                return;
            }

            /*函数返回值*/
            int result_printing = 0;
            int[] status = new int[4];
            byte[] RFIDDataByte = new byte[1024];
            var RFIDData = "";
            var PrinterStatus = "";

            /*获取打印机状态*/
            int[] status_Net = new int[4];
            result_printing = PrintLab.PTK_FeedBack();
            if (result_printing != 0) { showError("PTK_FeedBack", result_printing); return; }

            result_printing = PrintLab.PTK_ReadData(status_Net, 4);
            if (result_printing != 0) { showError("PTK_ReadData", result_printing); return; }

            PrinterStatus = status_Net[0] + "";

            if (!PrinterStatus.Equals("0"))
            {
                PrintLab.PTK_CloseConnect();
                MessageBox.Show("打印机未就绪，当前错误报告：" + Status_Explain(PrinterStatus));

                return;
            }



            /*清空缓存*/
            result_printing = PrintLab.PTK_ClearBuffer();
            if (result_printing != 0) { showError("PTK_ClearBuffer", result_printing); return; }

            /*读取UHF RFID 数据， 具体参数请查看API文档 */
            result_printing = PrintLab.PTK_ReadRFIDLabelData(2, 0, 1, RFIDDataByte, 1024);
            if (result_printing != 0)
            {
                int reee = PrintLab.PTK_GetLastError();
                showError("PTK_ReadRFIDLabelData:" + reee, result_printing); return;
            }

            RFIDData = Encoding.Default.GetString(RFIDDataByte).Trim('\0');



            /*断开打印机连接*/
            PrintLab.PTK_CloseConnect();


            MessageBox.Show("读取RFID数据成功：" + RFIDData);

        }

        private void EncodeAndlock_UHF_Click(object sender, EventArgs e)
        {
            /*
           *mm:点，毫米转为点，由打印机分辨率决定
           * 打印机分辨DPI=203时， mm=8
           * 打印机分辨DPI=300时， mm=12
           * 打印机分辨DPI=600时， mm=24
           */
            uint mm = 12;

            int result = 0;
            var message = "";

            /*连接打印机*/
            result = PrintLab.PTK_Connect_Timer(IPAddress, port, 2);
            if (result != 0)
            {
                result = getErrorInformation(result, out message);
                MessageBox.Show(message);
                return;
            }

            /*函数返回值*/
            int result_printing = 0;
            /*横坐标偏移,设置标签整体横向移动位置*/
            int offset_X = 0;

            /*纵坐标偏移，设置标签整体纵向移动位置*/
            int offset_Y = 0;

            /*获取打印机状态*/
            int[] status_Net = new int[4];
            String PrinterStatus = "";
            result_printing = PrintLab.PTK_FeedBack();
            if (result_printing != 0) { showError("PTK_FeedBack", result_printing); return; }

            result_printing = PrintLab.PTK_ReadData(status_Net, 4);
            if (result_printing != 0) { showError("PTK_ReadData", result_printing); return; }

            PrinterStatus = status_Net[0] + "";

            if (!PrinterStatus.Equals("0") && !PrinterStatus.Equals("4"))
            {
                PrintLab.PTK_CloseConnect();
                MessageBox.Show("打印机未就绪，当前错误报告：" + Status_Explain(PrinterStatus));

                return;
            }


            /*清空缓存*/
            result_printing = PrintLab.PTK_ClearBuffer();
            if (result_printing != 0) { showError("PTK_ClearBuffer", result_printing); return; }

            /*设置打印黑度 取值范围 0-20*/
            result_printing = PrintLab.PTK_SetDarkness(10);
            if (result_printing != 0) { showError("PTK_SetDarkness", result_printing); return; }

            /*设置打印速度*/
            result_printing = PrintLab.PTK_SetPrintSpeed(4);
            if (result_printing != 0) { showError("PTK_SetPrintSpeed", result_printing); return; }

            /*设置打印方向*/
            result_printing = PrintLab.PTK_SetDirection('B');
            if (result_printing != 0) { showError("PTK_SetDirection", result_printing); return; }

            /*设置标签高度、间隙及偏移*/
            result_printing = PrintLab.PTK_SetLabelHeight(19 * mm, 24, 0, false);
            if (result_printing != 0) { showError("PTK_SetLabelHeight", result_printing); return; }

            /*设置标签宽度，一定要准确，否则会导致打印内容位置不准确*/
            result_printing = PrintLab.PTK_SetLabelWidth(80 * mm);
            if (result_printing != 0) { showError("PTK_SetLabelWidth", result_printing); return; }

            /*UHF RFID打印设置具体参数请查看API文档*/
            result_printing = PrintLab.PTK_SetRFID(0, 0, 0, 0, 0);
            if (result_printing != 0) { showError("PTK_SetRFID", result_printing); return; }

            /*写RFID数据 具体参数请查看API文档  *^-^*写数据之前确保RFID标签已经校准成功*/
            result_printing = PrintLab.PTK_RWRFIDLabel(1, 0, 2, 4, 1, "12345678");
            if (result_printing != 0) { showError("PTK_RWRFIDLabel", result_printing); return; }

            /* 锁定RFID区域，锁定后要想重新写得先解锁。完全锁定后不能重写*/
            result_printing = PrintLab.PTK_SetRFLabelPWAndLockRFLabel(1, 4, "00000000");
            if (result_printing != 0) { showError("PTK_SetRFLabelPWAndLockRFLabel", result_printing); return; }
            /* 打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(80 + offset_X), (uint)(60 + offset_Y), 4 * mm, 0, E_UTF8("宋体"), 1, 400, false, false, false, E_UTF8("博思得科技发展有限公司"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印，必须要执行这一行，否则不会打印，打印多张标签时每张标签后面都需要加它*/
            result_printing = PrintLab.PTK_PrintLabel(1, 1);
            if (result_printing != 0) { showError("PTK_PrintLabel", result_printing); return; }



            /*断开打印机连接*/
            PrintLab.PTK_CloseConnect();


            MessageBox.Show("执行成功！");
        }

        private void Unlock_Encode_Lock_UHF_Click(object sender, EventArgs e)
        {
            /*
           *mm:点，毫米转为点，由打印机分辨率决定
           * 打印机分辨DPI=203时， mm=8
           * 打印机分辨DPI=300时， mm=12
           * 打印机分辨DPI=600时， mm=24
           */
            uint mm = 12;

            int result = 0;
            var message = "";

            /*连接打印机*/
            result = PrintLab.PTK_Connect_Timer(IPAddress, port, 2);
            if (result != 0)
            {
                result = getErrorInformation(result, out message);
                MessageBox.Show(message);
                return;
            }

            /*函数返回值*/
            int result_printing = 0;
            /*横坐标偏移,设置标签整体横向移动位置*/
            int offset_X = 0;

            /*纵坐标偏移，设置标签整体纵向移动位置*/
            int offset_Y = 0;

            /*获取打印机状态*/
            int[] status_Net = new int[4];
            String PrinterStatus = "";
            result_printing = PrintLab.PTK_FeedBack();
            if (result_printing != 0) { showError("PTK_FeedBack", result_printing); return; }

            result_printing = PrintLab.PTK_ReadData(status_Net, 4);
            if (result_printing != 0) { showError("PTK_ReadData", result_printing); return; }

            PrinterStatus = status_Net[0] + "";

            if (!PrinterStatus.Equals("0") && !PrinterStatus.Equals("4"))
            {
                PrintLab.PTK_CloseConnect();
                MessageBox.Show("打印机未就绪，当前错误报告：" + Status_Explain(PrinterStatus));

                return;
            }


            /*清空缓存*/
            result_printing = PrintLab.PTK_ClearBuffer();
            if (result_printing != 0) { showError("PTK_ClearBuffer", result_printing); return; }

            /*设置打印黑度 取值范围 0-20*/
            result_printing = PrintLab.PTK_SetDarkness(10);
            if (result_printing != 0) { showError("PTK_SetDarkness", result_printing); return; }

            /*设置打印速度*/
            result_printing = PrintLab.PTK_SetPrintSpeed(4);
            if (result_printing != 0) { showError("PTK_SetPrintSpeed", result_printing); return; }

            /*设置打印方向*/
            result_printing = PrintLab.PTK_SetDirection('B');
            if (result_printing != 0) { showError("PTK_SetDirection", result_printing); return; }

            /*设置标签高度、间隙及偏移*/
            result_printing = PrintLab.PTK_SetLabelHeight(19 * mm, 24, 0, false);
            if (result_printing != 0) { showError("PTK_SetLabelHeight", result_printing); return; }

            /*设置标签宽度，一定要准确，否则会导致打印内容位置不准确*/
            result_printing = PrintLab.PTK_SetLabelWidth(80 * mm);
            if (result_printing != 0) { showError("PTK_SetLabelWidth", result_printing); return; }

            /*UHF RFID打印设置具体参数请查看API文档*/
            result_printing = PrintLab.PTK_SetRFID(0, 0, 0, 0, 0);
            if (result_printing != 0) { showError("PTK_SetRFID", result_printing); return; }

            /*写RFID数据 具体参数请查看API文档  *^-^*写数据之前确保RFID标签已经校准成功*/
            result_printing = PrintLab.PTK_RWRFIDLabel(1, 0, 2, 4, 1, "12345678");
            if (result_printing != 0) { showError("PTK_RWRFIDLabel", result_printing); return; }

            /*解锁锁定的RFID区域*/
            result_printing = PrintLab.PTK_SetRFLabelPWAndLockRFLabel(0, 4, "00000000");
            if (result_printing != 0) { showError("PTK_SetRFLabelPWAndLockRFLabel", result_printing); return; }

            /* 锁定RFID区域，锁定后要想重新写得先解锁。完全锁定后不能重写*/
            result_printing = PrintLab.PTK_SetRFLabelPWAndLockRFLabel(1, 4, "00000000");
            if (result_printing != 0) { showError("PTK_SetRFLabelPWAndLockRFLabel", result_printing); return; }
            /* 打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(80 + offset_X), (uint)(60 + offset_Y), 4 * mm, 0, E_UTF8("宋体"), 1, 400, false, false, false, E_UTF8("博思得科技发展有限公司"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印，必须要执行这一行，否则不会打印，打印多张标签时每张标签后面都需要加它*/
            result_printing = PrintLab.PTK_PrintLabel(1, 1);
            if (result_printing != 0) { showError("PTK_PrintLabel", result_printing); return; }



            /*断开打印机连接*/
            PrintLab.PTK_CloseConnect();


            MessageBox.Show("执行成功！");
        }

        private void EncodeHFRFID_Click(object sender, EventArgs e)
        {
            /*
           *mm:点，毫米转为点，由打印机分辨率决定
           * 打印机分辨DPI=203时， mm=8
           * 打印机分辨DPI=300时， mm=12
           * 打印机分辨DPI=600时， mm=24
           */
            uint mm = 12;

            int result = 0;
            var message = "";

            /*连接打印机*/
            result = PrintLab.PTK_Connect_Timer(IPAddress, port, 2);
            if (result != 0)
            {
                result = getErrorInformation(result, out message);
                MessageBox.Show(message);
                return;
            }

            /*函数返回值*/
            int result_printing = 0;
            /*横坐标偏移,设置标签整体横向移动位置*/
            int offset_X = 0;

            /*纵坐标偏移，设置标签整体纵向移动位置*/
            int offset_Y = 0;

            /*获取打印机状态*/
            int[] status_Net = new int[4];
            String PrinterStatus = "";
            result_printing = PrintLab.PTK_FeedBack();
            if (result_printing != 0) { showError("PTK_FeedBack", result_printing); return; }

            result_printing = PrintLab.PTK_ReadData(status_Net, 4);
            if (result_printing != 0) { showError("PTK_ReadData", result_printing); return; }

            PrinterStatus = status_Net[0] + "";

            if (!PrinterStatus.Equals("0") && !PrinterStatus.Equals("4"))
            {
                PrintLab.PTK_CloseConnect();
                MessageBox.Show("打印机未就绪，当前错误报告：" + Status_Explain(PrinterStatus));

                return;
            }

            /*清空缓存*/
            result_printing = PrintLab.PTK_ClearBuffer();
            if (result_printing != 0) { showError("PTK_ClearBuffer", result_printing); return; }

            /*设置打印黑度 取值范围 0-20*/
            result_printing = PrintLab.PTK_SetDarkness(10);
            if (result_printing != 0) { showError("PTK_SetDarkness", result_printing); return; }

            /*设置打印速度*/
            result_printing = PrintLab.PTK_SetPrintSpeed(4);
            if (result_printing != 0) { showError("PTK_SetPrintSpeed", result_printing); return; }

            /*设置打印方向*/
            result_printing = PrintLab.PTK_SetDirection('B');
            if (result_printing != 0) { showError("PTK_SetDirection", result_printing); return; }

            /*设置标签高度、间隙及偏移*/
            result_printing = PrintLab.PTK_SetLabelHeight(29 * mm, 24, 0, false);
            if (result_printing != 0) { showError("PTK_SetLabelHeight", result_printing); return; }

            /*设置标签宽度，一定要准确，否则会导致打印内容位置不准确*/
            result_printing = PrintLab.PTK_SetLabelWidth(59 * mm);
            if (result_printing != 0) { showError("PTK_SetLabelWidth", result_printing); return; }

            /*高频（HF） RFID打印设置*/
            result_printing = PrintLab.PTK_SetHFRFID('H', 0, 0);
            if (result_printing != 0) { showError("PTK_SetHFRFID", result_printing); return; }

            /*写HF RFID数据 具体参数请查看API文档  *^-^*写数据之前确保RFID标签已经校准成功*/
            result_printing = PrintLab.PTK_RWHFLabel('W', 4, 8, "41414141395542687474703A2F2F7777772E62616964752E636F6D3F3D344544", false);
            if (result_printing != 0) { showError("PTK_RWRFIDLabel", result_printing); return; }

            /* 打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(80 + offset_X), (uint)(10 + offset_Y), 4 * mm, 0, E_UTF8("宋体"), 1, 400, false, false, false, E_UTF8("博思得科技发展有限公司"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印，必须要执行这一行，否则不会打印，打印多张标签时每张标签后面都需要加它*/
            result_printing = PrintLab.PTK_PrintLabel(1, 1);
            if (result_printing != 0) { showError("PTK_PrintLabel", result_printing); return; }



            /*断开打印机连接*/
            PrintLab.PTK_CloseConnect();

            MessageBox.Show("执行成功！");
        }

        private void ReadHFRFIDData_Click(object sender, EventArgs e)
        {
            int result = 0;
            var message = "";
            byte[] data = new byte[1024];
            byte[] status = new byte[10];

            var RFIDData = "";
            var PrinterStatus = "";
            /*函数返回值*/
            int result_printing = 0;

            /*连接打印机*/
            result = PrintLab.PTK_Connect_Timer(IPAddress, port, 2);
            if (result != 0)
            {
                result = getErrorInformation(result, out message);
                MessageBox.Show(message);
                return;
            }

            /*获取打印机状态*/
            int[] status_Net = new int[4];
            result_printing = PrintLab.PTK_FeedBack();
            if (result_printing != 0) { showError("PTK_FeedBack", result_printing); return; }

            result_printing = PrintLab.PTK_ReadData(status_Net, 4);
            if (result_printing != 0) { showError("PTK_ReadData", result_printing); return; }

            PrinterStatus = status_Net[0] + "";

            if (!PrinterStatus.Equals("0"))
            {
                PrintLab.PTK_CloseConnect();
                MessageBox.Show("打印机未就绪，当前错误报告：" + Status_Explain(PrinterStatus));

                return;
            }

            /*清空缓存*/
            result_printing = PrintLab.PTK_ClearBuffer();
            if (result_printing != 0) { showError("PTK_ClearBuffer", result_printing); return; }

            /*读取高频RFID 块数据*/
            //result_printing = PrintLab.PTK_ReadHFLabelData(1, 5, 'N', data, 256); //读取高频RFID块的数据
            /*读取高频RFID UID*/
            result_printing = PrintLab.PTK_ReadHFLabeUID('N', data, 256);
            if (result_printing != 0) { showError("PTK_ReadHFLabelData", result_printing); return; }
            RFIDData = Encoding.Default.GetString(data).Trim('\0');



            /*断开打印机连接*/
            PrintLab.PTK_CloseConnect();

            // Console.WriteLine("RFIDData:" + RFIDData + "\r\n"));
            MessageBox.Show("读取高频RFID数据成功：" + RFIDData);
        }

        private void PrinterStatus_Click(object sender, EventArgs e)
        {
            int result = 0;
            var message = "";

            /*函数返回值*/
            int result_printing = 0;

            /*连接打印机*/
            result = PrintLab.PTK_Connect_Timer(IPAddress, port, 2);
            if (result != 0)
            {
                result = getErrorInformation(result, out message);
                MessageBox.Show(message);
                return;
            }

            /*OX平台获取打印机状态*/
            byte[] status_Net_OX = new byte[1024];
            result_printing = PrintLab.PTK_GetPrinterStatus_Net_OX(status_Net_OX);
            if (result_printing != 0)
            {
                showError("PTK_GetPrinterStatus_Net_OX", result_printing);
                return;
            }

            /*断开打印机连接*/
            PrintLab.PTK_CloseConnect();

            // 去除末尾的空字符
            string statusCode = Encoding.UTF8.GetString(status_Net_OX).TrimEnd('\0');
            // 在消息框中显示打印机状态
            //MessageBox.Show("打印机状态：" + Status_Explain(statusCode));

        }
        private static String Status_Explain(String PrinterStatus)

        {
            switch (PrinterStatus)
            {
                case "EO_00000000": return "就绪";
                case "EO_00000001": return "正在打印";
                case "EO_00000002": return "打印暂停";
                case "EO_00000004": return "报错状态";
                case "EO_0000000C": return "打印头抬起";
                case "EO_80000008": return "测纸校准中";
                case "EO_80000001": return "贴标中";
                default: return "未知状态";

            }
        }


        private void PrintToFile_Click(object sender, EventArgs e)
        {
            /*
          *mm:点，毫米转为点，由打印机分辨率决定
          * 打印机分辨DPI=203时， mm=8
          * 打印机分辨DPI=300时， mm=12
          * 打印机分辨DPI=600时， mm=24
          */
            uint mm = 12;

            int result = 0;
            var message = "";

            /*创建一个文件，发送打印机的数据将被写入到该文件*/
            result = PrintLab.PTK_OpenTextPort("D:/printingData.txt"); ;
            if (result != 0)
            {
                result = getErrorInformation(result, out message);
                MessageBox.Show(message);
                return;
            }
            /*函数返回值*/
            int result_printing = 0;

            /*横坐标偏移,设置标签整体横向移动位置*/
            int offset_X = 0;

            /*纵坐标偏移，设置标签整体纵向移动位置*/
            int offset_Y = 0;

            /*清空缓存*/
            result_printing = PrintLab.PTK_ClearBuffer();
            if (result_printing != 0) { showError("PTK_ClearBuffer", result_printing); return; }

            /*设置打印黑度 取值范围 0-20*/
            result_printing = PrintLab.PTK_SetDarkness(10);
            if (result_printing != 0) { showError("PTK_SetDarkness", result_printing); return; }

            /*设置打印速度*/
            result_printing = PrintLab.PTK_SetPrintSpeed(4);
            if (result_printing != 0) { showError("PTK_SetPrintSpeed", result_printing); return; }

            /*设置打印方向*/
            result_printing = PrintLab.PTK_SetDirection('B');
            if (result_printing != 0) { showError("PTK_SetDirection", result_printing); return; }

            /*设置标签高度、间隙及偏移*/
            result_printing = PrintLab.PTK_SetLabelHeight(30 * mm, 24, 0, false);
            if (result_printing != 0) { showError("PTK_SetLabelHeight", result_printing); return; }

            /*设置标签宽度，一定要准确，否则会导致打印内容位置不准确*/
            result_printing = PrintLab.PTK_SetLabelWidth(50 * mm);
            if (result_printing != 0) { showError("PTK_SetLabelWidth", result_printing); return; }

            /*打印本地图片*/
            //result_printing = PrintLab.PTK_AnyGraphicsPrint((uint)(20 + offset_X), (uint)(20 + offset_Y),"picture","D;/POSTEK.png",1,0,0,0);
            //if (result_printing != 0) { showError("PTK_AnyGraphicsPrint",result_printing); return; }

            /*打印矩形*/
            result_printing = PrintLab.PTK_DrawRectangle((uint)(18 + offset_X), (uint)(12 + offset_Y), 4, 585, 343);
            if (result_printing != 0) { showError("PTK_DrawRectangle", result_printing); return; }

            /*打印一维码 此示例为Code128码*/
            result_printing = PrintLab.PTK_DrawBarcode((uint)(30 + offset_X), (uint)(99 + offset_Y), 0, "1", 2, 6, 40, 'N', E_UTF8("12345678"));//打印一维码
            if (result_printing != 0) { showError("PTK_DrawBarcode", result_printing); return; }

            /* 打印条码下方文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(30 + offset_X), (uint)(99 + 40 + 4 + offset_Y), 2 * mm, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("12345678"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /* 打印文字*/
            //result_printing = PrintLab.PTK_DrawText_TrueType((uint)(80 + offset_X), (uint)(180 + offset_Y), 4 * mm, 0, E_UTF8("宋体"), 1, 400, false, false, false, E_UTF8("博思得科技发展有限公司"));
            //if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }


            /*打印一维码 此示例为UPC码*/
            result_printing = PrintLab.PTK_DrawBarcode((uint)(213 + offset_X), (uint)(98 + offset_Y), 0, "UE0", 2, 6, 47, 'N', E_UTF8("234567"));
            if (result_printing != 0) { showError("PTK_DrawBarcode", result_printing); return; }

            /* 打印条码下方文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(213 + offset_X), (uint)(98 + 47 + 4 + offset_Y), 2 * mm, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("12345678"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印二维码 此示例为QR码 付款码就是这个码*/
            result_printing = PrintLab.PTK_DrawBar2D_QR((uint)(30 + offset_X), (uint)(182 + offset_Y), 0, 0, 0, 3, 4, 1, 8, E_UTF8("设计精湛 ABCD 1234 ^-^ @@ && $$ ￥￥"));
            if (result_printing != 0) { showError("PTK_DrawBar2D_QR", result_printing); return; }

            /*打印二维码 此示例为datamatrix码*/
            result_printing = PrintLab.PTK_DrawBar2D_DATAMATRIX((uint)(272 + offset_X), (uint)(182 + offset_Y), 0, 0, 0, 5, E_UTF8("设计精湛 ABCD 1234 ^-^ @@ && $$ ￥￥"));
            if (result_printing != 0) { showError("PTK_DrawBar2D_DATAMATRIX", result_printing); return; }

            /*打印二维码 此示例为PDF417码*/
            result_printing = PrintLab.PTK_DrawBar2D_Pdf417((uint)(25 + offset_X), (uint)(288 + offset_Y), 240, 38, 3, 0, 2, 2, 10, 6, 0, 0, E_UTF8("设计精湛 ABCD 1234 ^-^ @@ && $$ ￥￥"));
            if (result_printing != 0) { showError("PTK_DrawBar2D_Pdf417", result_printing); return; }

            /*打印二维码 此示例为汉信码*/
            result_printing = PrintLab.PTK_DrawBar2D_HANXIN((uint)(155 + offset_X), (uint)(182 + offset_Y), 0, 0, 0, 3, 3, 0, 0, E_UTF8("设计精湛 ABCD 1234 ^-^ @@ && $$ ￥￥"));
            if (result_printing != 0) { showError("PTK_DrawBar2D_HANXIN", result_printing); return; }

            /*打印斜线*/
            result_printing = PrintLab.PTK_DrawDiagonal((uint)(374 + offset_X), (uint)(343 + offset_Y), 4, 478, 222);
            if (result_printing != 0) { showError("PTK_DrawDiagonal", result_printing); return; }

            /*打印斜线*/
            result_printing = PrintLab.PTK_DrawDiagonal((uint)(478 + offset_X), (uint)(222 + offset_Y), 4, 585, 343);
            if (result_printing != 0) { showError("PTK_DrawDiagonal", result_printing); return; }

            /*打印直线*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(20 + offset_X), (uint)(90 + offset_Y), 562, 4);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /*打印直线*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(374 + offset_X), (uint)(90 + offset_Y), 4, 252);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /* 打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(112 + offset_X), (uint)(21 + offset_Y), 28, 0, E_UTF8("华文行楷"), 1, 400, false, false, false, E_UTF8("深圳市博思得科技发展有限公司"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /* 打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(125 + offset_X), (uint)(53 + offset_Y), 23, 0, E_UTF8("Magneto"), 1, 400, false, false, false, E_UTF8("Postek Electronics Co., Ltd."));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印，必须要执行这一行，否则不会打印，打印多张标签时每张标签后面都需要加它*/
            result_printing = PrintLab.PTK_PrintLabel(1, 1);
            if (result_printing != 0) { showError("PTK_PrintLabel", result_printing); return; }


            /*打印，必须要执行这一行，否则不会打印，打印多张标签时每张标签后面都需要加它*/
            result_printing = PrintLab.PTK_CloseTextPort();
            if (result_printing != 0) { showError("PTK_CloseTextPort", result_printing); return; }

        }

        private void PrintAJob_Click(object sender, EventArgs e)
        {

            /*
             *mm:点，毫米转为点，由打印机分辨率决定
             * 打印机分辨DPI=203时， mm=8
             * 打印机分辨DPI=300时， mm=12
             * 打印机分辨DPI=600时， mm=24
             */
            uint mm = 12;

            int result = 0;
            var message = "";

            /*连接打印机*/
            result = PrintLab.PTK_Connect_Timer(IPAddress, port, 2);
            if (result != 0)
            {
                result = getErrorInformation(result, out message);
                MessageBox.Show(message);
                return;
            }

            /*函数返回值*/
            int result_printing = 0;

            /*横坐标偏移,设置标签整体横向移动位置*/
            int offset_X = 0;

            /*纵坐标偏移，设置标签整体纵向移动位置*/
            int offset_Y = 0;

            /*获取打印机状态*/
            int[] status_Net = new int[4];
            String PrinterStatus = "";
            result_printing = PrintLab.PTK_FeedBack();
            if (result_printing != 0) { showError("PTK_FeedBack", result_printing); return; }

            result_printing = PrintLab.PTK_ReadData(status_Net, 4);
            if (result_printing != 0) { showError("PTK_ReadData", result_printing); return; }

            PrinterStatus = status_Net[0] + "";

            if (!PrinterStatus.Equals("0") && !PrinterStatus.Equals("4"))
            {
                PrintLab.PTK_CloseConnect();
                MessageBox.Show("打印机未就绪，当前错误报告：" + Status_Explain(PrinterStatus));

                return;
            }

            /*清空缓存*/
            result_printing = PrintLab.PTK_ClearBuffer();
            if (result_printing != 0) { showError("PTK_ClearBuffer", result_printing); return; }

            /*设置打印黑度 取值范围 0-20*/
            result_printing = PrintLab.PTK_SetDarkness(10);
            if (result_printing != 0) { showError("PTK_SetDarkness", result_printing); return; }

            /*设置打印速度*/
            result_printing = PrintLab.PTK_SetPrintSpeed(4);
            if (result_printing != 0) { showError("PTK_SetPrintSpeed", result_printing); return; }

            /*设置打印方向*/
            result_printing = PrintLab.PTK_SetDirection('B');
            if (result_printing != 0) { showError("PTK_SetDirection", result_printing); return; }

            /*设置标签高度、间隙及偏移*/
            result_printing = PrintLab.PTK_SetLabelHeight(30 * mm, 24, 0, false);
            if (result_printing != 0) { showError("PTK_SetLabelHeight", result_printing); return; }

            /*设置标签宽度，一定要准确，否则会导致打印内容位置不准确*/
            result_printing = PrintLab.PTK_SetLabelWidth(50 * mm);
            if (result_printing != 0) { showError("PTK_SetLabelWidth", result_printing); return; }


            for (int i = 0; i < 5; i++)
            {
                /*打印本地图片*/
                //result_printing = PrintLab.PTK_AnyGraphicsPrint((uint)(413 + offset_X), (uint)(135 + offset_Y), "logo", "D;/POSTEK.png", 0.6f, 92, 74, 0);
                /*打印网络图片*/
                result_printing = PrintLab.PTK_AnyGraphicsPrint((uint)(413 + offset_X), (uint)(135 + offset_Y), "logo", "https://www.postek.com.cn/print/logo.png", 0.6f, 92, 74, 0);
                if (result_printing != 0) { showError("PTK_AnyGraphicsPrint", result_printing); return; }

                /*打印矩形*/
                result_printing = PrintLab.PTK_DrawRectangle((uint)(18 + offset_X), (uint)(12 + offset_Y), 4, 585, 343);
                if (result_printing != 0) { showError("PTK_DrawRectangle", result_printing); return; }

                /*打印一维码 此示例为Code128码*/
                result_printing = PrintLab.PTK_DrawBarcode((uint)(30 + offset_X), (uint)(99 + offset_Y), 0, "1", 2, 6, 40, 'N', E_UTF8("12345678" + i));//打印一维码
                if (result_printing != 0) { showError("PTK_DrawBarcode", result_printing); return; }

                /* 打印条码下方文字*/
                result_printing = PrintLab.PTK_DrawText_TrueType((uint)(30 + offset_X), (uint)(99 + 40 + 4 + offset_Y), 2 * mm, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("12345678" + i));
                if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

                /* 打印文字*/
                //result_printing = PrintLab.PTK_DrawText_TrueType((uint)(80 + offset_X), (uint)(180 + offset_Y), 4 * mm, 0, E_UTF8("宋体"), 1, 400, false, false, false, E_UTF8("博思得科技发展有限公司"));
                //if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }


                /*打印一维码 此示例为UPC码*/
                result_printing = PrintLab.PTK_DrawBarcode((uint)(213 + offset_X), (uint)(98 + offset_Y), 0, "UE0", 2, 6, 47, 'B', E_UTF8("234567" + i));
                if (result_printing != 0) { showError("PTK_DrawBarcode", result_printing); return; }

                /* 打印条码下方文字*/
                result_printing = PrintLab.PTK_DrawText_TrueType((uint)(213 + offset_X), (uint)(98 + 47 + 4 + offset_Y), 2 * mm, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("12345678"));
                if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

                /*打印二维码 此示例为QR码 付款码就是这个码*/
                result_printing = PrintLab.PTK_DrawBar2D_QR((uint)(30 + offset_X), (uint)(182 + offset_Y), 0, 0, 0, 3, 4, 1, 8, E_UTF8("设计精湛 ABCD 1234 ^-^ @@ && $$ ￥￥" + i));
                if (result_printing != 0) { showError("PTK_DrawBar2D_QR", result_printing); return; }

                /*打印二维码 此示例为datamatrix码*/
                result_printing = PrintLab.PTK_DrawBar2D_DATAMATRIX((uint)(272 + offset_X), (uint)(182 + offset_Y), 0, 0, 0, 5, E_UTF8("设计精湛 ABCD 1234 ^-^ @@ && $$ ￥￥" + i));
                if (result_printing != 0) { showError("PTK_DrawBar2D_DATAMATRIX", result_printing); return; }

                /*打印二维码 此示例为PDF417码*/
                result_printing = PrintLab.PTK_DrawBar2D_Pdf417((uint)(25 + offset_X), (uint)(288 + offset_Y), 240, 38, 3, 0, 2, 2, 10, 6, 0, 0, E_UTF8("设计精湛 ABCD 1234 ^-^ @@ && $$ ￥￥" + i));
                if (result_printing != 0) { showError("PTK_DrawBar2D_Pdf417", result_printing); return; }

                /*打印二维码 此示例为汉信码*/
                result_printing = PrintLab.PTK_DrawBar2D_HANXIN((uint)(155 + offset_X), (uint)(182 + offset_Y), 0, 0, 0, 3, 3, 0, 0, E_UTF8("设计精湛 ABCD 1234 ^-^ @@ && $$ ￥￥" + i));
                if (result_printing != 0) { showError("PTK_DrawBar2D_HANXIN", result_printing); return; }

                /*打印斜线*/
                result_printing = PrintLab.PTK_DrawDiagonal((uint)(374 + offset_X), (uint)(343 + offset_Y), 4, 478, 222);
                if (result_printing != 0) { showError("PTK_DrawDiagonal", result_printing); return; }

                /*打印斜线*/
                result_printing = PrintLab.PTK_DrawDiagonal((uint)(478 + offset_X), (uint)(222 + offset_Y), 4, 585, 343);
                if (result_printing != 0) { showError("PTK_DrawDiagonal", result_printing); return; }

                /*打印直线*/
                result_printing = PrintLab.PTK_DrawLineOr((uint)(20 + offset_X), (uint)(90 + offset_Y), 562, 4);
                if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

                /*打印直线*/
                result_printing = PrintLab.PTK_DrawLineOr((uint)(374 + offset_X), (uint)(90 + offset_Y), 4, 252);
                if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

                /* 打印文字*/
                result_printing = PrintLab.PTK_DrawText_TrueType((uint)(112 + offset_X), (uint)(21 + offset_Y), 28, 0, E_UTF8("华文行楷"), 1, 400, false, false, false, E_UTF8("深圳市博思得科技发展有限公司"));
                if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

                /* 打印文字*/
                result_printing = PrintLab.PTK_DrawText_TrueType((uint)(125 + offset_X), (uint)(53 + offset_Y), 23, 0, E_UTF8("Magneto"), 1, 400, false, false, false, E_UTF8("Postek Electronics Co., Ltd."));
                if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

                /*打印，必须要执行这一行，否则不会打印，打印多张标签时每张标签后面都需要加它*/
                result_printing = PrintLab.PTK_PrintLabel(1, 1);
                if (result_printing != 0) { showError("PTK_PrintLabel", result_printing); return; }
            }



            /*断开打印机连接*/
            PrintLab.PTK_CloseConnect();
            MessageBox.Show("执行成功！");


        }

        private void PrintLabels_MultiCol_Click(object sender, EventArgs e)
        {
            /*
             *mm:点，毫米转为点，由打印机分辨率决定
             * 打印机分辨DPI=203时， mm=8
             * 打印机分辨DPI=300时， mm=12
             * 打印机分辨DPI=600时， mm=24
             */
            uint mm = 12;

            int result = 0;
            var message = "";
            /*标签有多少列*/
            uint column = 5;

            /*打印份数*/
            uint printNum = 11;

            /*单列标签的宽度 （每张小标签的宽度）*/
            uint width = 20 * mm;

            /*连接打印机*/
            result = PrintLab.PTK_Connect_Timer(IPAddress, port, 2);
            if (result != 0)
            {
                result = getErrorInformation(result, out message);
                MessageBox.Show(message);
                return;
            }

            /*函数返回值*/
            int result_printing = 0;
            /*横坐标偏移,设置标签整体横向移动位置*/
            int offset_X = 0;

            /*纵坐标偏移，设置标签整体纵向移动位置*/
            int offset_Y = 0;

            /*获取打印机状态*/
            int[] status_Net = new int[4];
            String PrinterStatus = "";
            result_printing = PrintLab.PTK_FeedBack();
            if (result_printing != 0) { showError("PTK_FeedBack", result_printing); return; }

            result_printing = PrintLab.PTK_ReadData(status_Net, 4);
            if (result_printing != 0) { showError("PTK_ReadData", result_printing); return; }

            PrinterStatus = status_Net[0] + "";

            if (!PrinterStatus.Equals("0") && !PrinterStatus.Equals("4"))
            {
                PrintLab.PTK_CloseConnect();
                MessageBox.Show("打印机未就绪，当前错误报告：" + Status_Explain(PrinterStatus));

                return;
            }

            /*清空缓存*/
            result_printing = PrintLab.PTK_ClearBuffer();
            if (result_printing != 0) { showError("PTK_ClearBuffer", result_printing); return; }

            /*设置打印黑度 取值范围 0-20*/
            result_printing = PrintLab.PTK_SetDarkness(10);
            if (result_printing != 0) { showError("PTK_SetDarkness", result_printing); return; }

            /*设置打印速度*/
            result_printing = PrintLab.PTK_SetPrintSpeed(4);
            if (result_printing != 0) { showError("PTK_SetPrintSpeed", result_printing); return; }

            /*设置打印方向*/
            result_printing = PrintLab.PTK_SetDirection('B');
            if (result_printing != 0) { showError("PTK_SetDirection", result_printing); return; }

            /*设置标签高度、间隙及偏移*/
            result_printing = PrintLab.PTK_SetLabelHeight(30 * mm, 24, 0, false);
            if (result_printing != 0) { showError("PTK_SetLabelHeight", result_printing); return; }

            /*设置标签宽度，一定要准确，否则会导致打印内容位置不准确*/
            result_printing = PrintLab.PTK_SetLabelWidth(104 * mm);
            if (result_printing != 0) { showError("PTK_SetLabelWidth", result_printing); return; }


            for (var i = 1; i < printNum + 1; i++)
            {
                /*计算当前处于第几行*/
                var row = i / column;

                /*用取余来判断当前处于第几列，由于i从1开始，所以当取余为0时恰好处于最后一列*/
                var col = i % column;

                /*如果取余得到的行号为0则为下一行*/
                var row_cr = col == 0 ? row : row + 1;

                /*当前处于的列数*/
                var col_cr = col == 0 ? column : col;

                /* 打印文字*/
                result_printing = PrintLab.PTK_DrawText_TrueType((uint)((col_cr - 1) * width + 80 + offset_X), (uint)(160 + offset_Y), 2 * mm, 0, E_UTF8("宋体"), 1, 400, false, false, false, E_UTF8("第" + row_cr + "行" + "第" + col_cr + "列"));
                if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

                /* 打印QR码*/
                result_printing = PrintLab.PTK_DrawBar2D_QREx((uint)((col_cr - 1) * width + 80 + offset_X), (uint)(10 + offset_Y), 0, 5, 1, 0, 8, "ss", E_UTF8("博思得科技发展有限公司"));
                if (result_printing != 0) { showError("PTK_DrawBar2D_QREx", result_printing); return; }
                Console.WriteLine("-------打印第" + row_cr + "行，第" + col_cr + "列");

                if (col == 0 || i == printNum)
                {
                    /*打印，必须要执行这一行，否则不会打印，打印多张标签时每张标签后面都需要加它*/
                    result_printing = PrintLab.PTK_PrintLabel(1, 1);
                    if (result_printing != 0) { showError("PTK_PrintLabel", result_printing); return; }
                }
            }



            /*断开打印机连接*/
            PrintLab.PTK_CloseConnect();


            MessageBox.Show("执行成功！");


        }

        private void EncodeRFID_Print_Job_Click(object sender, EventArgs e)
        {

            /*
            *mm:点，毫米转为点，由打印机分辨率决定
            * 打印机分辨DPI=203时， mm=8
            * 打印机分辨DPI=300时， mm=12
            * 打印机分辨DPI=600时， mm=24
            */
            uint mm = 12;

            int result = 0;
            var message = "";

            /*连接打印机*/
            result = PrintLab.PTK_Connect_Timer(IPAddress, port, 2);
            if (result != 0)
            {
                result = getErrorInformation(result, out message);
                MessageBox.Show(message);
                return;
            }

            /*函数返回值*/
            int result_printing = 0;
            /*横坐标偏移,设置标签整体横向移动位置*/
            int offset_X = 0;

            /*纵坐标偏移，设置标签整体纵向移动位置*/
            int offset_Y = 0;

            /*获取打印机状态*/
            int[] status_Net = new int[4];
            String PrinterStatus = "";
            result_printing = PrintLab.PTK_FeedBack();
            if (result_printing != 0) { showError("PTK_FeedBack", result_printing); return; }

            result_printing = PrintLab.PTK_ReadData(status_Net, 4);
            if (result_printing != 0) { showError("PTK_ReadData", result_printing); return; }

            PrinterStatus = status_Net[0] + "";

            if (!PrinterStatus.Equals("0") && !PrinterStatus.Equals("4"))
            {
                PrintLab.PTK_CloseConnect();
                MessageBox.Show("打印机未就绪，当前错误报告：" + Status_Explain(PrinterStatus));

                return;
            }

            /*清空缓存*/
            result_printing = PrintLab.PTK_ClearBuffer();
            if (result_printing != 0) { showError("PTK_ClearBuffer", result_printing); return; }

            /*设置打印黑度 取值范围 0-20*/
            result_printing = PrintLab.PTK_SetDarkness(10);
            if (result_printing != 0) { showError("PTK_SetDarkness", result_printing); return; }

            /*设置打印速度*/
            result_printing = PrintLab.PTK_SetPrintSpeed(4);
            if (result_printing != 0) { showError("PTK_SetPrintSpeed", result_printing); return; }

            /*设置打印方向*/
            result_printing = PrintLab.PTK_SetDirection('B');
            if (result_printing != 0) { showError("PTK_SetDirection", result_printing); return; }

            /*设置标签高度、间隙及偏移*/
            result_printing = PrintLab.PTK_SetLabelHeight(19 * mm, 24, 0, false);
            if (result_printing != 0) { showError("PTK_SetLabelHeight", result_printing); return; }

            /*设置标签宽度，一定要准确，否则会导致打印内容位置不准确*/
            result_printing = PrintLab.PTK_SetLabelWidth(80 * mm);
            if (result_printing != 0) { showError("PTK_SetLabelWidth", result_printing); return; }

            for (int i = 0; i < 4; i++)
            {

                /*UHF RFID打印设置具体参数请查看API文档*/
                result_printing = PrintLab.PTK_SetRFID(0, 0, 0, 1, 0);
                if (result_printing != 0) { showError("PTK_SetRFID", result_printing); return; }

                /*写RFID数据 具体参数请查看API文档  *^-^*写数据之前确保RFID标签已经校准成功*/
                result_printing = PrintLab.PTK_RWRFIDLabel(1, 0, 0, 16, 1, "4C14F7E75CF8E73C32C30C30C30C31D2");
                if (result_printing != 0) { showError("PTK_RWRFIDLabel", result_printing); return; }

                /* 打印文字*/
                result_printing = PrintLab.PTK_DrawText_TrueType((uint)(93 + offset_X), (uint)(65 + offset_Y), 53, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("SAS795389302000000014" + i));
                if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

                /* 打印QR码*/
                result_printing = PrintLab.PTK_DrawBar2D_QR((uint)(23 + offset_X), (uint)(61 + offset_Y), 0, 0, 0, 3, 4, 1, 8, E_UTF8("SAS795389302000000014" + i));
                if (result_printing != 0) { showError("PTK_DrawBar2D_QR", result_printing); return; }


                /*打印，必须要执行这一行，否则不会打印，打印多张标签时每张标签后面都需要加它*/
                result_printing = PrintLab.PTK_PrintLabel(1, 1);
                if (result_printing != 0) { showError("PTK_PrintLabel", result_printing); return; }

            }



            /*断开打印机连接*/
            PrintLab.PTK_CloseConnect();


            MessageBox.Show("执行成功！");
        }

        private void ReadRFID_Print_job_Click(object sender, EventArgs e)
        {
            /*
             *mm:点，毫米转为点，由打印机分辨率决定
             * 打印机分辨DPI=203时， mm=8
             * 打印机分辨DPI=300时， mm=12
             * 打印机分辨DPI=600时， mm=24
             */
            uint mm = 12;

            int result = 0;
            var message = "";

            /*连接打印机*/
            result = PrintLab.PTK_Connect_Timer(IPAddress, port, 2);
            if (result != 0)
            {
                result = getErrorInformation(result, out message);
                MessageBox.Show(message);
                return;
            }


            byte[] data = new byte[1024];
            byte[] status = new byte[10];
            String RFIDData = "";
            String PrinterStatus = "";
            byte[] RFIDDataByte = new byte[1024];
            /*函数返回值*/
            int result_printing = 0;

            /*横坐标偏移,设置标签整体横向移动位置*/
            int offset_X = 0;

            /*纵坐标偏移，设置标签整体纵向移动位置*/
            int offset_Y = 0;


            /*获取打印机状态*/
            int[] status_Net = new int[4];
            result_printing = PrintLab.PTK_FeedBack();
            if (result_printing != 0) { showError("PTK_FeedBack", result_printing); return; }

            result_printing = PrintLab.PTK_ReadData(status_Net, 4);
            if (result_printing != 0) { showError("PTK_ReadData", result_printing); return; }

            PrinterStatus = status_Net[0] + "";

            if (!PrinterStatus.Equals("0"))
            {
                PrintLab.PTK_CloseConnect();
                MessageBox.Show("打印机未就绪，当前错误报告：" + Status_Explain(PrinterStatus));

                return;
            }


            for (int i = 0; i < 2; i++)
            {

                if (!PrinterStatus.Equals("0"))
                {
                    PrintLab.PTK_CloseConnect();
                    MessageBox.Show("打印机未就绪，当前错误报告：" + Status_Explain(PrinterStatus));

                    return;
                }

                /*清空缓存*/
                result_printing = PrintLab.PTK_ClearBuffer();
                if (result_printing != 0) { showError("PTK_ClearBuffer", result_printing); return; }

                /*读取UHF RFID 数据， 具体参数请查看API文档 */
                result_printing = PrintLab.PTK_ReadRFIDLabelData(2, 0, 1, RFIDDataByte, 1024);
                if (result_printing != 0)
                {
                    int reee = PrintLab.PTK_GetLastError();
                    showError("PTK_ReadRFIDLabelData:" + reee, result_printing); return;
                }

                RFIDData = Encoding.Default.GetString(RFIDDataByte).Trim('\0');


                /*清空缓存*/
                result_printing = PrintLab.PTK_ClearBuffer();
                if (result_printing != 0) { showError("PTK_ClearBuffer", result_printing); return; }

                /*设置打印黑度 取值范围 0-20*/
                result_printing = PrintLab.PTK_SetDarkness(10);
                if (result_printing != 0) { showError("PTK_SetDarkness", result_printing); return; }

                /*设置打印速度*/
                result_printing = PrintLab.PTK_SetPrintSpeed(4);
                if (result_printing != 0) { showError("PTK_SetPrintSpeed", result_printing); return; }

                /*设置打印方向*/
                result_printing = PrintLab.PTK_SetDirection('B');
                if (result_printing != 0) { showError("PTK_SetDirection", result_printing); return; }

                /*设置标签高度、间隙及偏移*/
                result_printing = PrintLab.PTK_SetLabelHeight(19 * mm, 24, 0, false);
                if (result_printing != 0) { showError("PTK_SetLabelHeight", result_printing); return; }

                /*设置标签宽度，一定要准确，否则会导致打印内容位置不准确*/
                result_printing = PrintLab.PTK_SetLabelWidth(80 * mm);
                if (result_printing != 0) { showError("PTK_SetLabelWidth", result_printing); return; }

                /*UHF RFID打印设置具体参数请查看API文档*/
                result_printing = PrintLab.PTK_SetRFID(0, 0, 0, 0, 0);
                if (result_printing != 0) { showError("PTK_SetRFID", result_printing); return; }

                /*写RFID数据 具体参数请查看API文档  *^-^*写数据之前确保RFID标签已经校准成功*/
                result_printing = PrintLab.PTK_RWRFIDLabel(1, 0, 0, 16, 1, "4C14F7E75CF8E73C32C30C30C30C31D2");
                if (result_printing != 0) { showError("PTK_RWRFIDLabel", result_printing); return; }

                /* 打印文字*/
                result_printing = PrintLab.PTK_DrawText_TrueType((uint)(93 + offset_X), (uint)(65 + offset_Y), 53, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("SAS795389302000000014" + i));
                if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

                /* 打印QR码*/
                result_printing = PrintLab.PTK_DrawBar2D_QR((uint)(23 + offset_X), (uint)(61 + offset_Y), 0, 0, 0, 3, 4, 1, 8, E_UTF8("SAS795389302000000014" + i));
                if (result_printing != 0) { showError("PTK_DrawBar2D_QR", result_printing); return; }


                result_printing = PrintLab.PTK_PrintLabelFeedback(status, 8);
                if (result_printing != 0) { showError("PTK_PrintLabelFeedback", result_printing); return; }

                PrinterStatus = int.Parse(Encoding.Default.GetString(status).Trim('\0').Replace("W1", "")) + "";

            }




            /*断开打印机连接*/
            PrintLab.PTK_CloseConnect();
            MessageBox.Show("执行成功！\r\n");

        }

        private void EncodeRFID_Read_Print_job_Click(object sender, EventArgs e)
        {
            /*
             *mm:点，毫米转为点，由打印机分辨率决定
             * 打印机分辨DPI=203时， mm=8
             * 打印机分辨DPI=300时， mm=12
             * 打印机分辨DPI=600时， mm=24
             */
            uint mm = 12;

            int result = 0;
            var message = "";

            /*连接打印机*/
            result = PrintLab.PTK_Connect_Timer(IPAddress, port, 2);
            if (result != 0)
            {
                result = getErrorInformation(result, out message);
                MessageBox.Show(message);
                return;
            }

            byte[] data = new byte[10240];
            byte[] status = new byte[48];
            var RFIDData = "";
            var PrinterStatus = "";
            /*函数返回值*/
            int result_printing = 0;

            /*横坐标偏移,设置标签整体横向移动位置*/
            int offset_X = 0;

            /*纵坐标偏移，设置标签整体纵向移动位置*/
            int offset_Y = 0;



            /*获取打印机状态*/
            int[] status_Net = new int[4];
            result_printing = PrintLab.PTK_FeedBack();
            if (result_printing != 0) { showError("PTK_FeedBack", result_printing); return; }

            result_printing = PrintLab.PTK_ReadData(status_Net, 4);
            if (result_printing != 0) { showError("PTK_ReadData", result_printing); return; }

            PrinterStatus = status_Net[0] + "";

            if (!PrinterStatus.Equals("0"))
            {
                PrintLab.PTK_CloseConnect();
                MessageBox.Show("打印机未就绪，当前错误报告：" + Status_Explain(PrinterStatus));

                return;
            }


            for (int i = 0; i < 1; i++)
            {

                /*清空缓存*/
                result_printing = PrintLab.PTK_ClearBuffer();
                if (result_printing != 0) { showError("PTK_ClearBuffer", result_printing); return; }

                /*设置打印黑度 取值范围 0-20*/
                result_printing = PrintLab.PTK_SetDarkness(10);
                if (result_printing != 0) { showError("PTK_SetDarkness", result_printing); return; }

                /*设置打印速度*/
                result_printing = PrintLab.PTK_SetPrintSpeed(4);
                if (result_printing != 0) { showError("PTK_SetPrintSpeed", result_printing); return; }

                /*设置打印方向*/
                result_printing = PrintLab.PTK_SetDirection('B');
                if (result_printing != 0) { showError("PTK_SetDirection", result_printing); return; }

                /*设置标签高度、间隙及偏移*/
                result_printing = PrintLab.PTK_SetLabelHeight(19 * mm, 24, 0, false);
                if (result_printing != 0) { showError("PTK_SetLabelHeight", result_printing); return; }

                /*设置标签宽度，一定要准确，否则会导致打印内容位置不准确*/
                result_printing = PrintLab.PTK_SetLabelWidth(80 * mm);
                if (result_printing != 0) { showError("PTK_SetLabelWidth", result_printing); return; }

                /*UHF RFID打印设置具体参数请查看API文档*/
                result_printing = PrintLab.PTK_SetRFID(0, 0, 0, 0, 0);
                if (result_printing != 0) { showError("PTK_SetRFID", result_printing); return; }

                /*写RFID数据 具体参数请查看API文档  *^-^*写数据之前确保RFID标签已经校准成功*/
                result_printing = PrintLab.PTK_RWRFIDLabel(1, 0, 0, 16, 1, "4C14F7E75CF8E73C32C30C30C30C31D2");
                if (result_printing != 0) { showError("PTK_RWRFIDLabel", result_printing); return; }

                /* 打印文字*/
                result_printing = PrintLab.PTK_DrawText_TrueType((uint)(93 + offset_X), (uint)(65 + offset_Y), 53, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("SAS795389302000000014" + i));
                if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

                /* 打印QR码*/
                result_printing = PrintLab.PTK_DrawBar2D_QR((uint)(23 + offset_X), (uint)(61 + offset_Y), 0, 0, 0, 3, 4, 1, 8, E_UTF8("SAS795389302000000014" + i));
                if (result_printing != 0) { showError("PTK_DrawBar2D_QR", result_printing); return; }


                /**打印并返回RFID数据和打印机状态 此函数仅支 持 V 1 0 0 以上固件
                result_printing = PrintLab.PTK_ReadRFIDSetting(2, 0, 5, "00000000") ;
                if (result_printing != 0) { showError("PTK_ReadRFIDSetting", result_printing); return; }
                result_printing = PrintLab.PTK_PrintAndCallback(data, status);
                if (result_printing != 0) { showError("PTK_PrintAndCallback", result_printing); return; }
                */

                /*打印并返回RFID数据和打印机状态*/
                result_printing = PrintLab.PTK_RFIDEndPrintLabelFeedBack(2, data, 10240, status, 48);
                if (result_printing != 0) { showError("PTK_RFIDEndPrintLabelFeedBack", result_printing); return; }

                RFIDData = Encoding.Default.GetString(data).Trim('\0');
                PrinterStatus = Encoding.Default.GetString(status).Trim('\0');
                Console.WriteLine(RFIDData + PrinterStatus);

            }


            /*断开打印机连接*/
            PrintLab.PTK_CloseConnect();
            MessageBox.Show("执行成功！\r\n" + "RFIDData:" + RFIDData + "\r\nPrinterStatus:" + PrinterStatus);

        }

        private void Print_ResturnRFIDData_Click(object sender, EventArgs e)
        {

            /*
            *mm:点，毫米转为点，由打印机分辨率决定
            * 打印机分辨DPI=203时， mm=8
            * 打印机分辨DPI=300时， mm=12
            * 打印机分辨DPI=600时， mm=24
            */
            uint mm = 12;

            int result = 0;
            var message = "";
            byte[] data = new byte[1024];
            var RFIDData = "";
            /*连接打印机*/
            result = PrintLab.PTK_Connect_Timer(IPAddress, port, 2);
            if (result != 0)
            {
                result = getErrorInformation(result, out message);
                MessageBox.Show(message);
                return;
            }

            /*函数返回值*/
            int result_printing = 0;
            /*横坐标偏移,设置标签整体横向移动位置*/
            int offset_X = 0;

            /*纵坐标偏移，设置标签整体纵向移动位置*/
            int offset_Y = 0;

            /*获取打印机状态*/
            int[] status_Net = new int[4];
            String PrinterStatus = "";
            result_printing = PrintLab.PTK_FeedBack();
            if (result_printing != 0) { showError("PTK_FeedBack", result_printing); return; }

            result_printing = PrintLab.PTK_ReadData(status_Net, 4);
            if (result_printing != 0) { showError("PTK_ReadData", result_printing); return; }

            PrinterStatus = status_Net[0] + "";

            if (!PrinterStatus.Equals("0") && !PrinterStatus.Equals("4"))
            {
                PrintLab.PTK_CloseConnect();
                MessageBox.Show("打印机未就绪，当前错误报告：" + Status_Explain(PrinterStatus));

                return;
            }

            /*清空缓存*/
            result_printing = PrintLab.PTK_ClearBuffer();
            if (result_printing != 0) { showError("PTK_ClearBuffer", result_printing); return; }

            /*设置打印黑度 取值范围 0-20*/
            result_printing = PrintLab.PTK_SetDarkness(10);
            if (result_printing != 0) { showError("PTK_SetDarkness", result_printing); return; }

            /*设置打印速度*/
            result_printing = PrintLab.PTK_SetPrintSpeed(4);
            if (result_printing != 0) { showError("PTK_SetPrintSpeed", result_printing); return; }

            /*设置打印方向*/
            result_printing = PrintLab.PTK_SetDirection('B');
            if (result_printing != 0) { showError("PTK_SetDirection", result_printing); return; }

            /*设置标签高度、间隙及偏移*/
            result_printing = PrintLab.PTK_SetLabelHeight(19 * mm, 24, 0, false);
            if (result_printing != 0) { showError("PTK_SetLabelHeight", result_printing); return; }

            /*设置标签宽度，一定要准确，否则会导致打印内容位置不准确*/
            result_printing = PrintLab.PTK_SetLabelWidth(80 * mm);
            if (result_printing != 0) { showError("PTK_SetLabelWidth", result_printing); return; }

            /*UHF RFID打印设置具体参数请查看API文档*/
            result_printing = PrintLab.PTK_SetRFID(0, 0, 0, 2, 0);
            if (result_printing != 0) { showError("PTK_SetRFID", result_printing); return; }

            /*写RFID数据 具体参数请查看API文档  *^-^*写数据之前确保RFID标签已经校准成功*/
            result_printing = PrintLab.PTK_RWRFIDLabel(1, 0, 0, 16, 1, "4C14F7E75CF8E73C32C30C30C30C31D2");
            if (result_printing != 0) { showError("PTK_RWRFIDLabel", result_printing); return; }

            /* 打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(93 + offset_X), (uint)(65 + offset_Y), 53, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("SAS795389302000000014"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /* 打印QR码*/
            result_printing = PrintLab.PTK_DrawBar2D_QR((uint)(23 + offset_X), (uint)(61 + offset_Y), 0, 0, 0, 3, 4, 1, 8, E_UTF8("SAS795389302000000014"));
            if (result_printing != 0) { showError("PTK_DrawBar2D_QR", result_printing); return; }

            /*打印，必须要执行这一行，否则不会打印，打印多张标签时每张标签后面都需要加它*/
            result_printing = PrintLab.PTK_RFIDEndPrintLabel(2, data, 1024);
            if (result_printing != 0) { showError("PTK_RFIDEndPrintLabel", result_printing); return; }
            RFIDData = Encoding.Default.GetString(data).Trim('\0');




            /*断开打印机连接*/
            PrintLab.PTK_CloseConnect();


            MessageBox.Show("执行成功并返回RFID数据：" + RFIDData);
        }

        private void WashLabel_Click(object sender, EventArgs e)
        {
            /*
             *mm:点，毫米转为点，由打印机分辨率决定
             * 打印机分辨DPI=203时， mm=8
             * 打印机分辨DPI=300时， mm=12
             * 打印机分辨DPI=600时， mm=24
             */
            uint mm = 12;

            int result = 0;
            var message = "";

            /*连接打印机*/
            result = PrintLab.PTK_Connect_Timer(IPAddress, port, 2);
            if (result != 0)
            {
                result = getErrorInformation(result, out message);
                MessageBox.Show(message);
                return;
            }

            /*函数返回值*/
            int result_printing = 0;
            /*横坐标偏移,设置标签整体横向移动位置*/
            int offset_X = 0;

            /*纵坐标偏移，设置标签整体纵向移动位置*/
            int offset_Y = 0;


            /*获取打印机状态*/
            int[] status_Net = new int[4];
            String PrinterStatus = "";
            result_printing = PrintLab.PTK_FeedBack();
            if (result_printing != 0) { showError("PTK_FeedBack", result_printing); return; }

            result_printing = PrintLab.PTK_ReadData(status_Net, 4);
            if (result_printing != 0) { showError("PTK_ReadData", result_printing); return; }

            PrinterStatus = status_Net[0] + "";

            if (!PrinterStatus.Equals("0") && !PrinterStatus.Equals("4"))
            {
                PrintLab.PTK_CloseConnect();
                MessageBox.Show("打印机未就绪，当前错误报告：" + Status_Explain(PrinterStatus));

                return;
            }


            /*清空缓存*/
            result_printing = PrintLab.PTK_ClearBuffer();
            if (result_printing != 0) { showError("PTK_ClearBuffer", result_printing); return; }

            /*设置打印黑度 取值范围 0-20*/
            result_printing = PrintLab.PTK_SetDarkness(10);
            if (result_printing != 0) { showError("PTK_SetDarkness", result_printing); return; }

            /*设置打印速度*/
            result_printing = PrintLab.PTK_SetPrintSpeed(4);
            if (result_printing != 0) { showError("PTK_SetPrintSpeed", result_printing); return; }

            /*设置打印方向*/
            result_printing = PrintLab.PTK_SetDirection('B');
            if (result_printing != 0) { showError("PTK_SetDirection", result_printing); return; }

            /*设置标签高度、间隙及偏移 打印洗水唛打印机不需要校准标签，标签间隙设置为0*/
            result_printing = PrintLab.PTK_SetLabelHeight(90 * mm, 0, 0, false);
            if (result_printing != 0) { showError("PTK_SetLabelHeight", result_printing); return; }

            /*设置标签宽度，一定要准确，否则会导致打印内容位置不准确*/
            result_printing = PrintLab.PTK_SetLabelWidth(30 * mm);
            if (result_printing != 0) { showError("PTK_SetLabelWidth", result_printing); return; }

            /* 打印一维码*/
            result_printing = PrintLab.PTK_DrawBarcode((uint)(21 + offset_X), (uint)(827 + offset_Y), 0, "E30", 3, 9, 81, 'N', E_UTF8("694773135006"));
            if (result_printing != 0) { showError("PTK_DrawBarcode", result_printing); return; }

            /* 打印条码下方文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(21 + offset_X), (uint)(827 + 81 + 4 + offset_Y), 29, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("品牌：博思得"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /* 打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(19 + offset_X), (uint)(102 + offset_Y), 29, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("品牌：博思得"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /* 打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(19 + offset_X), (uint)(137 + offset_Y), 33, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("品名：短袖衬衣"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /* 打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(19 + offset_X), (uint)(175 + offset_Y), 33, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("等级：一等品"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /* 打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(19 + offset_X), (uint)(214 + offset_Y), 29, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("检验员：008"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /* 打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(19 + offset_X), (uint)(248 + offset_Y), 29, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("执行标注：GB/T2660-2008"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /* 打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(19 + offset_X), (uint)(283 + offset_Y), 29, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("货号：X112920392-B3"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /* 打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(19 + offset_X), (uint)(317 + offset_Y), 33, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("号型：180/96A(52)"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /* 打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(19 + offset_X), (uint)(356 + offset_Y), 29, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("颜色：黑色"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /* 打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(19 + offset_X), (uint)(391 + offset_Y), 29, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("面料成份：100%棉"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /* 打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(19 + offset_X), (uint)(425 + offset_Y), 33, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("安全类别：B类(直接接触皮肤)"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /* 打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(19 + offset_X), (uint)(464 + offset_Y), 29, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("洗涤说明："));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /* 打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(119 + offset_X), (uint)(503 + offset_Y), 29, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("最高洗涤温度30℃"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /* 打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(119 + offset_X), (uint)(533 + offset_Y), 29, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("温和程序"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /* 打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(119 + offset_X), (uint)(591 + offset_Y), 29, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("不可漂白"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /* 打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(85 + offset_X), (uint)(939 + offset_Y), 44, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("产地：广州"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /* 打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(119 + offset_X), (uint)(774 + offset_Y), 29, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("常规干洗"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /* 打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(119 + offset_X), (uint)(699 + offset_Y), 29, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("烫斗底板"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /* 打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(119 + offset_X), (uint)(651 + offset_Y), 29, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("悬挂晾干"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /* 打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(119 + offset_X), (uint)(730 + offset_Y), 29, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("最高温度150℃"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /* 打印本地图片*/
            result_printing = PrintLab.PTK_AnyGraphicsPrint((uint)(32 + offset_X), (uint)(510 + offset_Y), "WT30", "./logo/WT30.bmp", 0.2f, 82, 49, 0); //打印图片,此处为了方便演示图片内置
            if (result_printing != 0) { showError("PTK_AnyGraphicsPrint", result_printing); return; }

            result_printing = PrintLab.PTK_AnyGraphicsPrint((uint)(32 + offset_X), (uint)(588 + offset_Y), "DoNotBleach", CurrentDirectory + "\\logo\\DoNotBleach.bmp", 0.17f, 92, 74, 0); //打印图片，此处为了方便演示图片内置
            if (result_printing != 0) { showError("PTK_AnyGraphicsPrint", result_printing); return; }

            /* 打印本地图片*/
            result_printing = PrintLab.PTK_AnyGraphicsPrint((uint)(42 + offset_X), (uint)(646 + offset_Y), "HangToDry", CurrentDirectory + "\\logo\\HangToDry.bmp", 0.15f, 82, 49, 0); //打印图片,此处为了方便演示图片内置
            if (result_printing != 0) { showError("PTK_AnyGraphicsPrint", result_printing); return; }

            /* 打印本地图片*/
            result_printing = PrintLab.PTK_AnyGraphicsPrint((uint)(37 + offset_X), (uint)(710 + offset_Y), "hot150", CurrentDirectory + "\\logo\\hot150.bmp", 0.19f, 92, 74, 0); //打印图片，此处为了方便演示图片内置
            if (result_printing != 0) { showError("PTK_AnyGraphicsPrint", result_printing); return; }

            /* 打印本地图片*/
            result_printing = PrintLab.PTK_AnyGraphicsPrint((uint)(42 + offset_X), (uint)(759 + offset_Y), "DryCleaning", CurrentDirectory + "\\logo\\DryCleaning.bmp", 0.14f, 92, 74, 0); //打印图片，此处为了方便演示图片内置
            if (result_printing != 0) { showError("PTK_AnyGraphicsPrint", result_printing); return; }

            /* 打印本地图片*/
            result_printing = PrintLab.PTK_AnyGraphicsPrint((uint)(16 + offset_X), (uint)(33 + offset_Y), "logo", CurrentDirectory + "\\logo\\logo.jpg", 0.8f, 92, 74, 0); //打印图片，此处为了方便演示图片内置
            if (result_printing != 0) { showError("PTK_AnyGraphicsPrint", result_printing); return; }

            /*打印，必须要执行这一行，否则不会打印，打印多张标签时每张标签后面都需要加它*/
            result_printing = PrintLab.PTK_PrintLabel(1, 1);
            if (result_printing != 0) { showError("PTK_PrintLabel", result_printing); return; }



            /*断开打印机连接*/
            PrintLab.PTK_CloseConnect();


            MessageBox.Show("执行成功！");
        }

        private void Fixed_Assets_Click(object sender, EventArgs e)
        {
            /*
             *mm:点，毫米转为点，由打印机分辨率决定
             * 打印机分辨DPI=203时， mm=8
             * 打印机分辨DPI=300时， mm=12
             * 打印机分辨DPI=600时， mm=24
             */
            uint mm = 12;

            int result = 0;
            var message = "";

            /*连接打印机*/
            result = PrintLab.PTK_Connect_Timer(IPAddress, port, 2);
            if (result != 0)
            {
                result = getErrorInformation(result, out message);
                MessageBox.Show(message);
                return;
            }

            /*函数返回值*/
            int result_printing = 0;
            /*横坐标偏移,设置标签整体横向移动位置*/
            int offset_X = 0;

            /*纵坐标偏移，设置标签整体纵向移动位置*/
            int offset_Y = 0;


            /*获取打印机状态*/
            int[] status_Net = new int[4];
            String PrinterStatus = "";
            result_printing = PrintLab.PTK_FeedBack();
            if (result_printing != 0) { showError("PTK_FeedBack", result_printing); return; }

            result_printing = PrintLab.PTK_ReadData(status_Net, 4);
            if (result_printing != 0) { showError("PTK_ReadData", result_printing); return; }

            PrinterStatus = status_Net[0] + "";

            if (!PrinterStatus.Equals("0") && !PrinterStatus.Equals("4"))
            {
                PrintLab.PTK_CloseConnect();
                MessageBox.Show("打印机未就绪，当前错误报告：" + Status_Explain(PrinterStatus));

                return;
            }


            /*清空缓存*/
            result_printing = PrintLab.PTK_ClearBuffer();
            if (result_printing != 0) { showError("PTK_ClearBuffer", result_printing); return; }

            /*设置打印黑度 取值范围 0-20*/
            result_printing = PrintLab.PTK_SetDarkness(10);
            if (result_printing != 0) { showError("PTK_SetDarkness", result_printing); return; }

            /*设置打印速度*/
            result_printing = PrintLab.PTK_SetPrintSpeed(4);
            if (result_printing != 0) { showError("PTK_SetPrintSpeed", result_printing); return; }

            /*设置打印方向*/
            result_printing = PrintLab.PTK_SetDirection('B');
            if (result_printing != 0) { showError("PTK_SetDirection", result_printing); return; }

            /*设置标签高度、间隙及偏移 */
            result_printing = PrintLab.PTK_SetLabelHeight(18 * mm, 24, 0, false);
            if (result_printing != 0) { showError("PTK_SetLabelHeight", result_printing); return; }

            /*设置标签宽度，一定要准确，否则会导致打印内容位置不准确*/
            result_printing = PrintLab.PTK_SetLabelWidth(71 * mm);
            if (result_printing != 0) { showError("PTK_SetLabelWidth", result_printing); return; }

            /* 打印一维码*/
            result_printing = PrintLab.PTK_DrawBarcode((uint)(21 + offset_X), (uint)(827 + offset_Y), 0, "E30", 3, 9, 81, 'N', E_UTF8("694773135006"));
            if (result_printing != 0) { showError("PTK_DrawBarcode", result_printing); return; }

            /* 打印条码下方文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(21 + offset_X), (uint)(827 + 81 + 4 + offset_Y), 29, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("品牌：博思得"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /* 打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(165 + offset_X), (uint)(10 + offset_Y), 42, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("XXXX银行      档案资产管理")); //打印文字
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /* 打印矩形*/
            result_printing = PrintLab.PTK_DrawRectangle((uint)(23 + offset_X), (uint)(5 + offset_Y), 4, 817, 204);
            if (result_printing != 0) { showError("PTK_DrawRectangle", result_printing); return; }

            /* 打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(24 + offset_X), (uint)(51 + offset_Y), 791, 4);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /* 打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(24 + offset_X), (uint)(87 + offset_Y), 791, 4);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /* 打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(24 + offset_X), (uint)(126 + offset_Y), 791, 4);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }


            /* 打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(24 + offset_X), (uint)(163 + offset_Y), 541, 4);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /* 打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(41 + offset_X), (uint)(56 + offset_Y), 29, 0, E_UTF8("黑体"), 1, 400, false, false, false, E_UTF8("储存编号"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /* 打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(199 + offset_X), (uint)(59 + offset_Y), 29, 0, E_UTF8("黑体"), 1, 400, false, false, false, E_UTF8("02200800201512250185"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /* 打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(28 + offset_X), (uint)(94 + offset_Y), 25, 0, E_UTF8("黑体"), 1, 400, false, false, false, E_UTF8("档案封签编号"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /* 打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(45 + offset_X), (uint)(132 + offset_Y), 29, 0, E_UTF8("黑体"), 1, 400, false, false, false, E_UTF8("档案所属"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /* 打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(45 + offset_X), (uint)(168 + offset_Y), 29, 0, E_UTF8("黑体"), 1, 400, false, false, false, E_UTF8("机构名称"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /* 打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(503 + offset_X), (uint)(60 + offset_Y), 25, 0, E_UTF8("黑体"), 1, 400, false, false, false, E_UTF8("档案类型"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /* 打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(515 + offset_X), (uint)(88 + offset_Y), 4, 39);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /* 打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(501 + offset_X), (uint)(51 + offset_Y), 4, 38);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /* 打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(217 + offset_X), (uint)(97 + offset_Y), 29, 0, E_UTF8("黑体"), 1, 400, false, false, false, E_UTF8("A01252951"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /* 打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(408 + offset_X), (uint)(96 + offset_Y), 29, 0, E_UTF8("黑体"), 1, 400, false, false, false, E_UTF8("客户号"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /* 打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(597 + offset_X), (uint)(98 + offset_Y), 29, 0, E_UTF8("黑体"), 1, 400, false, false, false, E_UTF8("2000403916"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /* 打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(202 + offset_X), (uint)(133 + offset_Y), 29, 0, E_UTF8("黑体"), 1, 400, false, false, false, E_UTF8("广东省深圳市XXXX有限公司"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /* 打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(202 + offset_X), (uint)(170 + offset_Y), 29, 0, E_UTF8("黑体"), 1, 400, false, false, false, E_UTF8("广东省深圳市分行"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /* 打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(624 + offset_X), (uint)(57 + offset_Y), 29, 0, E_UTF8("黑体"), 1, 400, false, false, false, E_UTF8("房产抵押合同"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /* 打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(609 + offset_X), (uint)(53 + offset_Y), 4, 36);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /* 打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(188 + offset_X), (uint)(50 + offset_Y), 4, 153);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /* 打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(563 + offset_X), (uint)(129 + offset_Y), 4, 75);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /* 打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(358 + offset_X), (uint)(89 + offset_Y), 4, 38);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /* 打印一维码*/
            result_printing = PrintLab.PTK_DrawBarcode((uint)(602 + offset_X), (uint)(133 + offset_Y), 0, "1", 1, 3, 39, 'N', E_UTF8("A01252951"));
            if (result_printing != 0) { showError("PTK_DrawBarcode", result_printing); return; }

            /* 打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(594 + offset_X), (uint)(172 + offset_Y), 25, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("A01252951"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印，必须要执行这一行，否则不会打印，打印多张标签时每张标签后面都需要加它*/
            result_printing = PrintLab.PTK_PrintLabel(1, 1);
            if (result_printing != 0) { showError("PTK_PrintLabel", result_printing); return; }



            /*断开打印机连接*/
            PrintLab.PTK_CloseConnect();


            MessageBox.Show("执行成功！");

        }

        private void Clothing_tag_Click(object sender, EventArgs e)
        {
            /*
             *mm:点，毫米转为点，由打印机分辨率决定
             * 打印机分辨DPI=203时， mm=8
             * 打印机分辨DPI=300时， mm=12
             * 打印机分辨DPI=600时， mm=24
             */
            uint mm = 12;

            int result = 0;
            var message = "";

            /*连接打印机*/
            result = PrintLab.PTK_Connect_Timer(IPAddress, port, 2);
            if (result != 0)
            {
                result = getErrorInformation(result, out message);
                MessageBox.Show(message);
                return;
            }

            /*函数返回值*/
            int result_printing = 0;
            /*横坐标偏移,设置标签整体横向移动位置*/
            int offset_X = 0;

            /*纵坐标偏移，设置标签整体纵向移动位置*/
            int offset_Y = 0;


            /*获取打印机状态*/
            int[] status_Net = new int[4];
            String PrinterStatus = "";
            result_printing = PrintLab.PTK_FeedBack();
            if (result_printing != 0) { showError("PTK_FeedBack", result_printing); return; }

            result_printing = PrintLab.PTK_ReadData(status_Net, 4);
            if (result_printing != 0) { showError("PTK_ReadData", result_printing); return; }

            PrinterStatus = status_Net[0] + "";

            if (!PrinterStatus.Equals("0") && !PrinterStatus.Equals("4"))
            {
                PrintLab.PTK_CloseConnect();
                MessageBox.Show("打印机未就绪，当前错误报告：" + Status_Explain(PrinterStatus));

                return;
            }


            /*清空缓存*/
            result_printing = PrintLab.PTK_ClearBuffer();
            if (result_printing != 0) { showError("PTK_ClearBuffer", result_printing); return; }

            /*设置打印黑度 取值范围 0-20*/
            result_printing = PrintLab.PTK_SetDarkness(10);
            if (result_printing != 0) { showError("PTK_SetDarkness", result_printing); return; }

            /*设置打印速度*/
            result_printing = PrintLab.PTK_SetPrintSpeed(4);
            if (result_printing != 0) { showError("PTK_SetPrintSpeed", result_printing); return; }

            /*设置打印方向*/
            result_printing = PrintLab.PTK_SetDirection('B');
            if (result_printing != 0) { showError("PTK_SetDirection", result_printing); return; }

            /*设置标签高度、间隙及偏移 */
            result_printing = PrintLab.PTK_SetLabelHeight(80 * mm, 24, 0, false);
            if (result_printing != 0) { showError("PTK_SetLabelHeight", result_printing); return; }

            /*设置标签宽度，一定要准确，否则会导致打印内容位置不准确*/
            result_printing = PrintLab.PTK_SetLabelWidth(40 * mm);
            if (result_printing != 0) { showError("PTK_SetLabelWidth", result_printing); return; }

            /*打印条码*/
            result_printing = PrintLab.PTK_DrawBarcode((uint)(46 + offset_X), (uint)(712 + offset_Y), 0, "1A", 3, 9, 94, 'N', E_UTF8("T6225560"));
            if (result_printing != 0) { showError("PTK_DrawBarcode", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(162 + offset_X), (uint)(818 + offset_Y), 33, 0, E_UTF8("黑体"), 1, 800, false, false, false, E_UTF8("T6225560"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(164 + offset_X), (uint)(40 + offset_Y), 48, 0, E_UTF8("黑体"), 1, 800, false, false, false, E_UTF8("合格证"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(47 + offset_X), (uint)(139 + offset_Y), 42, 0, E_UTF8("黑体"), 1, 800, false, false, false, E_UTF8("货号："));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(174 + offset_X), (uint)(121 + offset_Y), 63, 0, E_UTF8("黑体"), 1, 800, false, false, false, E_UTF8("T6225560"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(50 + offset_X), (uint)(204 + offset_Y), 42, 0, E_UTF8("黑体"), 1, 800, false, false, false, E_UTF8("品名："));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(53 + offset_X), (uint)(279 + offset_Y), 33, 0, E_UTF8("黑体"), 1, 800, false, false, false, E_UTF8("颜色："));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(50 + offset_X), (uint)(346 + offset_Y), 33, 0, E_UTF8("黑体"), 1, 800, false, false, false, E_UTF8("规格："));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(50 + offset_X), (uint)(407 + offset_Y), 33, 0, E_UTF8("黑体"), 1, 800, false, false, false, E_UTF8("等级："));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(58 + offset_X), (uint)(461 + offset_Y), 33, 0, E_UTF8("黑体"), 1, 800, false, false, false, E_UTF8("质检员：  01"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(48 + offset_X), (uint)(512 + offset_Y), 33, 0, E_UTF8("黑体"), 1, 800, false, false, false, E_UTF8("安全类别：    B类"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(49 + offset_X), (uint)(564 + offset_Y), 33, 21, E_UTF8("黑体"), 1, 400, false, false, false, E_UTF8("执行标准：FZ/T73008-2002"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(167 + offset_X), (uint)(210 + offset_Y), 25, 0, E_UTF8("黑体"), 1, 400, false, false, false, E_UTF8("女装圆领T恤蕾丝花边针"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(167 + offset_X), (uint)(235 + offset_Y), 25, 0, E_UTF8("黑体"), 1, 800, false, false, false, E_UTF8("织修身连体裙"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(206 + offset_X), (uint)(277 + offset_Y), 54, 0, E_UTF8("黑体"), 1, 800, false, false, false, E_UTF8("红色"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(195 + offset_X), (uint)(340 + offset_Y), 33, 0, E_UTF8("黑体"), 1, 800, false, false, false, E_UTF8("110/52"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(47 + offset_X), (uint)(608 + offset_Y), 25, 0, E_UTF8("黑体"), 1, 400, false, false, false, E_UTF8("羊毛拉架面料  65%棉  30%"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(47 + offset_X), (uint)(633 + offset_Y), 25, 0, E_UTF8("黑体"), 1, 800, false, false, false, E_UTF8("聚酯纤维  5%氨纶"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(206 + offset_X), (uint)(402 + offset_Y), 25, 0, E_UTF8("黑体"), 1, 800, false, false, false, E_UTF8("合格品"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(39 + offset_X), (uint)(666 + offset_Y), 42, 0, E_UTF8("黑体"), 1, 800, false, false, false, E_UTF8("JA12001532"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(54 + offset_X), (uint)(862 + offset_Y), 46, 0, E_UTF8("黑体"), 1, 800, false, false, false, E_UTF8("零售价：￥59.00"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印本地*/
            result_printing = PrintLab.PTK_AnyGraphicsPrint((uint)(355 + offset_X), (uint)(292 + offset_Y), "hot200", CurrentDirectory + "\\logo\\hot200.bmp", 0, 82, 49, 0);
            if (result_printing != 0) { showError("PTK_AnyGraphicsPrint", result_printing); return; }

            //*打印本地*/
            result_printing = PrintLab.PTK_AnyGraphicsPrint((uint)(347 + offset_X), (uint)(409 + offset_Y), "DoNotWash", CurrentDirectory + "\\logo\\DoNotWash.bmp", 0.3f, 92, 74, 0);
            if (result_printing != 0) { showError("PTK_AnyGraphicsPrint", result_printing); return; }

            /*打印，必须要执行这一行，否则不会打印，打印多张标签时每张标签后面都需要加它*/
            result_printing = PrintLab.PTK_PrintLabel(1, 1);
            if (result_printing != 0) { showError("PTK_PrintLabel", result_printing); return; }



            /*断开打印机连接*/
            PrintLab.PTK_CloseConnect();


            MessageBox.Show("执行成功！");
        }

        private void Price_Tag_Click(object sender, EventArgs e)
        {
            /*
             *mm:点，毫米转为点，由打印机分辨率决定
             * 打印机分辨DPI=203时， mm=8
             * 打印机分辨DPI=300时， mm=12
             * 打印机分辨DPI=600时， mm=24
             */
            uint mm = 12;

            int result = 0;
            var message = "";

            /*连接打印机*/
            result = PrintLab.PTK_Connect_Timer(IPAddress, port, 2);
            if (result != 0)
            {
                result = getErrorInformation(result, out message);
                MessageBox.Show(message);
                return;
            }

            /*函数返回值*/
            int result_printing = 0;
            /*横坐标偏移,设置标签整体横向移动位置*/
            int offset_X = 0;

            /*纵坐标偏移，设置标签整体纵向移动位置*/
            int offset_Y = 0;


            /*获取打印机状态*/
            int[] status_Net = new int[4];
            String PrinterStatus = "";
            result_printing = PrintLab.PTK_FeedBack();
            if (result_printing != 0) { showError("PTK_FeedBack", result_printing); return; }

            result_printing = PrintLab.PTK_ReadData(status_Net, 4);
            if (result_printing != 0) { showError("PTK_ReadData", result_printing); return; }

            PrinterStatus = status_Net[0] + "";

            if (!PrinterStatus.Equals("0") && !PrinterStatus.Equals("4"))
            {
                PrintLab.PTK_CloseConnect();
                MessageBox.Show("打印机未就绪，当前错误报告：" + Status_Explain(PrinterStatus));

                return;
            }


            /*清空缓存*/
            result_printing = PrintLab.PTK_ClearBuffer();
            if (result_printing != 0) { showError("PTK_ClearBuffer", result_printing); return; }

            /*设置打印黑度 取值范围 0-20*/
            result_printing = PrintLab.PTK_SetDarkness(10);
            if (result_printing != 0) { showError("PTK_SetDarkness", result_printing); return; }

            /*设置打印速度*/
            result_printing = PrintLab.PTK_SetPrintSpeed(4);
            if (result_printing != 0) { showError("PTK_SetPrintSpeed", result_printing); return; }

            /*设置打印方向*/
            result_printing = PrintLab.PTK_SetDirection('B');
            if (result_printing != 0) { showError("PTK_SetDirection", result_printing); return; }

            /*设置标签高度、间隙及偏移 */
            result_printing = PrintLab.PTK_SetLabelHeight(130 * mm, 24, 0, false);
            if (result_printing != 0) { showError("PTK_SetLabelHeight", result_printing); return; }

            /*设置标签宽度，一定要准确，否则会导致打印内容位置不准确*/
            result_printing = PrintLab.PTK_SetLabelWidth(90 * mm);
            if (result_printing != 0) { showError("PTK_SetLabelWidth", result_printing); return; }

            /*打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(offset_X + 0), (uint)(offset_Y + 496), 1063, 12);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /*打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(offset_X + 647), (uint)(offset_Y + 499), 12, 403);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /*打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(offset_X + 0), (uint)(offset_Y + 899), 1063, 12);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /*打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(offset_X + 0), (uint)(offset_Y + 1226), 1063, 12);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /*打印矩形*/
            result_printing = PrintLab.PTK_DrawRectangle((uint)(offset_X + 653), (uint)(offset_Y + 503), 4, 1063, 623);
            if (result_printing != 0) { showError("PTK_DrawRectangle", result_printing); return; }

            /*打印一维码*/
            result_printing = PrintLab.PTK_DrawBarcode((uint)(offset_X + 137), (uint)(offset_Y + 939), 0, "1", 5, 15, 188, 'N', E_UTF8("23883106000260001840"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印QR码*/
            result_printing = PrintLab.PTK_DrawBar2D_QR((uint)(offset_X + 804), (uint)(offset_Y + 168), 0, 0, 0, 7, 0, 0, 8, E_UTF8("产地：云南 销售商：深圳市博思得科技发展有限公司"));
            if (result_printing != 0) { showError("PTK_DrawBar2D_QR", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 326), (uint)(offset_Y + 17), 58, 0, E_UTF8("Arial"), 1, 800, false, false, false, E_UTF8("特选上海青"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 95), (uint)(offset_Y + 90), 58, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("SELECTED  GREEN  BRASSICA"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 10), (uint)(offset_Y + 216), 58, 0, E_UTF8("Arial"), 1, 800, false, false, false, E_UTF8("上海青常温"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 8), (uint)(offset_Y + 308), 55, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("CEYLON SPINACH AMBIENT"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 7), (uint)(offset_Y + 414), 58, 0, E_UTF8("Arial"), 1, 800, false, false, false, E_UTF8("生产日期/Production date:"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 721), (uint)(offset_Y + 411), 57, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("2012-03-23"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 7), (uint)(offset_Y + 518), 38, 0, E_UTF8("Arial"), 1, 800, false, false, false, E_UTF8("此日期或之前食用"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 402), (uint)(offset_Y + 519), 38, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("2012-03-23"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 7), (uint)(offset_Y + 577), 38, 0, E_UTF8("Arial"), 1, 800, false, false, false, E_UTF8("Use by"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 7), (uint)(offset_Y + 633), 38, 0, E_UTF8("Arial"), 1, 800, false, false, false, E_UTF8("每斤单价"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 7), (uint)(offset_Y + 681), 38, 0, E_UTF8("Arial"), 1, 800, false, false, false, E_UTF8("￥/"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 109), (uint)(offset_Y + 678), 38, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("500g"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 7), (uint)(offset_Y + 734), 38, 0, E_UTF8("Arial"), 1, 800, false, false, false, E_UTF8("净重/数量"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 306), (uint)(offset_Y + 679), 38, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("6.98"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 284), (uint)(offset_Y + 735), 38, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("0.184"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 7), (uint)(offset_Y + 785), 38, 0, E_UTF8("Arial"), 1, 800, false, false, false, E_UTF8("Net WT/Quantity"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            //result_printing = PrintLab.PTK_SetCharSets(8, 'U', "001");
            //if (result_printing != 0) { showError("PTK_SetCharSets", result_printing); return; }

            /*调用打印机内置字体打印*/
            result_printing = PrintLab.PTK_DrawText((uint)(offset_X + 655), (uint)(offset_Y + 514), 0, '6', 2, 4, 'R', E_UTF8("零售价:Total Price(￥)"));
            if (result_printing != 0) { showError("PTK_DrawText", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 742), (uint)(offset_Y + 645), 146, 0, E_UTF8("Arial"), 1, 800, false, false, false, E_UTF8("2.60"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 249), (uint)(offset_Y + 1127), 50, 0, E_UTF8("Arial"), 1, 800, false, false, false, E_UTF8("23883106000260001840"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 7), (uint)(offset_Y + 1254), 33, 0, E_UTF8("Arial"), 1, 800, false, false, false, E_UTF8("标价员："));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 153), (uint)(offset_Y + 1254), 33, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("李明明"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 503), (uint)(offset_Y + 1251), 33, 0, E_UTF8("Arial"), 1, 800, false, false, false, E_UTF8("产地："));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 685), (uint)(offset_Y + 1247), 33, 0, E_UTF8("Arial"), 1, 800, false, false, false, E_UTF8("云南"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 503), (uint)(offset_Y + 1301), 33, 0, E_UTF8("Arial"), 1, 800, false, false, false, E_UTF8("Origin:"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 696), (uint)(offset_Y + 1301), 33, 0, E_UTF8("Arial"), 1, 800, false, false, false, E_UTF8("YN"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 7), (uint)(offset_Y + 1302), 33, 0, E_UTF8("Arial"), 1, 800, false, false, false, E_UTF8("Pricing by:"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 7), (uint)(offset_Y + 1345), 33, 0, E_UTF8("Arial"), 1, 800, false, false, false, E_UTF8("销售商/Sell by:"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 245), (uint)(offset_Y + 1347), 33, 0, E_UTF8("Arial"), 1, 800, false, false, false, E_UTF8("POSTEK"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 7), (uint)(offset_Y + 1393), 33, 0, E_UTF8("Arial"), 1, 800, false, false, false, E_UTF8("电话/Tell:"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 188), (uint)(offset_Y + 1389), 33, 0, E_UTF8("Arial"), 1, 800, false, false, false, E_UTF8("0755-83240988"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 9), (uint)(offset_Y + 1447), 33, 0, E_UTF8("Arial"), 1, 800, false, false, false, E_UTF8("地址/Address:"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 237), (uint)(offset_Y + 1446), 33, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("深圳市南山区侨香路4068号"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印，必须要执行这一行，否则不会打印，打印多张标签时每张标签后面都需要加它*/
            result_printing = PrintLab.PTK_PrintLabel(1, 1);
            if (result_printing != 0) { showError("PTK_PrintLabel", result_printing); return; }



            /*断开打印机连接*/
            PrintLab.PTK_CloseConnect();


            MessageBox.Show("执行成功！");
        }

        private void Electronic_Product_body_label_Click(object sender, EventArgs e)
        {
            /*
             *mm:点，毫米转为点，由打印机分辨率决定
             * 打印机分辨DPI=203时， mm=8
             * 打印机分辨DPI=300时， mm=12
             * 打印机分辨DPI=600时， mm=24
             */
            uint mm = 12;

            int result = 0;
            var message = "";

            /*连接打印机*/
            result = PrintLab.PTK_Connect_Timer(IPAddress, port, 2);
            if (result != 0)
            {
                result = getErrorInformation(result, out message);
                MessageBox.Show(message);
                return;
            }

            /*函数返回值*/
            int result_printing = 0;
            /*横坐标偏移,设置标签整体横向移动位置*/
            int offset_X = 0;

            /*纵坐标偏移，设置标签整体纵向移动位置*/
            int offset_Y = 0;

            /*获取打印机状态*/
            int[] status_Net = new int[4];
            String PrinterStatus = "";
            result_printing = PrintLab.PTK_FeedBack();
            if (result_printing != 0) { showError("PTK_FeedBack", result_printing); return; }

            result_printing = PrintLab.PTK_ReadData(status_Net, 4);
            if (result_printing != 0) { showError("PTK_ReadData", result_printing); return; }

            PrinterStatus = status_Net[0] + "";

            if (!PrinterStatus.Equals("0") && !PrinterStatus.Equals("4"))
            {
                PrintLab.PTK_CloseConnect();
                MessageBox.Show("打印机未就绪，当前错误报告：" + Status_Explain(PrinterStatus));

                return;
            }


            /*清空缓存*/
            result_printing = PrintLab.PTK_ClearBuffer();
            if (result_printing != 0) { showError("PTK_ClearBuffer", result_printing); return; }

            /*设置打印黑度 取值范围 0-20*/
            result_printing = PrintLab.PTK_SetDarkness(10);
            if (result_printing != 0) { showError("PTK_SetDarkness", result_printing); return; }

            /*设置打印速度*/
            result_printing = PrintLab.PTK_SetPrintSpeed(4);
            if (result_printing != 0) { showError("PTK_SetPrintSpeed", result_printing); return; }

            /*设置打印方向*/
            result_printing = PrintLab.PTK_SetDirection('B');
            if (result_printing != 0) { showError("PTK_SetDirection", result_printing); return; }

            /*设置标签高度、间隙及偏移 */
            result_printing = PrintLab.PTK_SetLabelHeight(19 * mm, 24, 0, false);
            if (result_printing != 0) { showError("PTK_SetLabelHeight", result_printing); return; }

            /*设置标签宽度，一定要准确，否则会导致打印内容位置不准确*/
            result_printing = PrintLab.PTK_SetLabelWidth(28 * mm);
            if (result_printing != 0) { showError("PTK_SetLabelWidth", result_printing); return; }

            /*打印条码*/
            result_printing = PrintLab.PTK_DrawBarcode((uint)(offset_X + 80), (uint)(offset_Y + 104), 0, "1", 2, 6, 21, 'N', E_UTF8("S35962050897892"));
            if (result_printing != 0) { showError("PTK_DrawBarcode", result_printing); return; }

            /*打印条码*/
            result_printing = PrintLab.PTK_DrawBarcode((uint)(offset_X + 80), (uint)(offset_Y + 145), 0, "1", 2, 6, 21, 'N', E_UTF8("S35962050897902"));
            if (result_printing != 0) { showError("PTK_DrawBarcode", result_printing); return; }

            /*打印条码*/
            result_printing = PrintLab.PTK_DrawBarcode((uint)(offset_X + 80), (uint)(offset_Y + 104), 0, "1", 2, 6, 21, 'N', E_UTF8("S35962050897892"));
            if (result_printing != 0) { showError("PTK_DrawBarcode", result_printing); return; }

            /*打印条码*/
            result_printing = PrintLab.PTK_DrawBarcode((uint)(offset_X + 80), (uint)(offset_Y + 145), 0, "1", 2, 6, 21, 'N', E_UTF8("S35962050897902"));
            if (result_printing != 0) { showError("PTK_DrawBarcode", result_printing); return; }

            /*打印条码*/
            result_printing = PrintLab.PTK_DrawBarcode((uint)(offset_X + 80), (uint)(offset_Y + 62), 0, "0", 2, 6, 21, 'N', E_UTF8("LM172070"));
            if (result_printing != 0) { showError("PTK_DrawBarcode", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 80), (uint)(offset_Y + 86), 19, 0, E_UTF8("微软雅黑"), 1, 400, false, false, false, E_UTF8("IMEI1: S35962050897892"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 57), (uint)(offset_Y + 25), 17, 0, E_UTF8("微软雅黑"), 1, 800, false, false, false, E_UTF8("Model:LM-754 S"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 80), (uint)(offset_Y + 128), 19, 0, E_UTF8("微软雅黑"), 1, 400, false, false, false, E_UTF8("IMEI2: S35962050897902"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 99), (uint)(offset_Y + 175), 17, 0, E_UTF8("微软雅黑"), 1, 400, false, false, false, E_UTF8("Fabricante:Blend United"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 57), (uint)(offset_Y + 2), 21, 0, E_UTF8("微软雅黑"), 1, 800, false, false, false, E_UTF8("Sensi 2"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 170), (uint)(offset_Y + 6), 17, 0, E_UTF8("微软雅黑"), 1, 400, false, false, false, E_UTF8("Anatel: 05588-16-03242"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 80), (uint)(offset_Y + 86), 19, 0, E_UTF8("微软雅黑"), 1, 400, false, false, false, E_UTF8("IMEI1: S35962050897892"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 57), (uint)(offset_Y + 25), 17, 0, E_UTF8("微软雅黑"), 1, 400, false, false, false, E_UTF8("Model:LM-754 S"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 80), (uint)(offset_Y + 128), 19, 0, E_UTF8("微软雅黑"), 1, 400, false, false, false, E_UTF8("IMEI2: S35962050897902"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 99), (uint)(offset_Y + 175), 17, 0, E_UTF8("微软雅黑"), 1, 400, false, false, false, E_UTF8("Fabricante:Blend United"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 57), (uint)(offset_Y + 2), 21, 0, E_UTF8("微软雅黑"), 1, 800, false, false, false, E_UTF8("Sensi 2"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 98), (uint)(offset_Y + 195), 16, 0, E_UTF8("微软雅黑"), 1, 400, false, false, false, E_UTF8("Blend United Technology Co.,Ltd."));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 80), (uint)(offset_Y + 45), 19, 0, E_UTF8("微软雅黑"), 1, 400, false, false, false, E_UTF8("S/N: LM172070"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 42), (uint)(offset_Y + 164), 17, 0, E_UTF8("微软雅黑"), 4, 400, false, false, false, E_UTF8("Made in China"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印，必须要执行这一行，否则不会打印，打印多张标签时每张标签后面都需要加它*/
            result_printing = PrintLab.PTK_PrintLabel(1, 1);
            if (result_printing != 0) { showError("PTK_PrintLabel", result_printing); return; }



            /*断开打印机连接*/
            PrintLab.PTK_CloseConnect();


            MessageBox.Show("执行成功！");
        }

        private void Electronic_Product_Box_Label_Click(object sender, EventArgs e)
        {
            /*
             *mm:点，毫米转为点，由打印机分辨率决定
             * 打印机分辨DPI=203时， mm=8
             * 打印机分辨DPI=300时， mm=12
             * 打印机分辨DPI=600时， mm=24
             */
            uint mm = 12;

            int result = 0;
            var message = "";

            /*连接打印机*/
            result = PrintLab.PTK_Connect_Timer(IPAddress, port, 2);
            if (result != 0)
            {
                result = getErrorInformation(result, out message);
                MessageBox.Show(message);
                return;
            }

            /*函数返回值*/
            int result_printing = 0;
            /*横坐标偏移,设置标签整体横向移动位置*/
            int offset_X = 0;

            /*纵坐标偏移，设置标签整体纵向移动位置*/
            int offset_Y = 0;


            /*获取打印机状态*/
            int[] status_Net = new int[4];
            String PrinterStatus = "";
            result_printing = PrintLab.PTK_FeedBack();
            if (result_printing != 0) { showError("PTK_FeedBack", result_printing); return; }

            result_printing = PrintLab.PTK_ReadData(status_Net, 4);
            if (result_printing != 0) { showError("PTK_ReadData", result_printing); return; }

            PrinterStatus = status_Net[0] + "";

            if (!PrinterStatus.Equals("0") && !PrinterStatus.Equals("4"))
            {
                PrintLab.PTK_CloseConnect();
                MessageBox.Show("打印机未就绪，当前错误报告：" + Status_Explain(PrinterStatus));

                return;
            }


            /*清空缓存*/
            result_printing = PrintLab.PTK_ClearBuffer();
            if (result_printing != 0) { showError("PTK_ClearBuffer", result_printing); return; }

            /*设置打印黑度 取值范围 0-20*/
            result_printing = PrintLab.PTK_SetDarkness(10);
            if (result_printing != 0) { showError("PTK_SetDarkness", result_printing); return; }

            /*设置打印速度*/
            result_printing = PrintLab.PTK_SetPrintSpeed(4);
            if (result_printing != 0) { showError("PTK_SetPrintSpeed", result_printing); return; }

            /*设置打印方向*/
            result_printing = PrintLab.PTK_SetDirection('B');
            if (result_printing != 0) { showError("PTK_SetDirection", result_printing); return; }

            /*设置标签高度、间隙及偏移 */
            result_printing = PrintLab.PTK_SetLabelHeight(102 * mm, 24, 0, false);
            if (result_printing != 0) { showError("PTK_SetLabelHeight", result_printing); return; }

            /*设置标签宽度，一定要准确，否则会导致打印内容位置不准确*/
            result_printing = PrintLab.PTK_SetLabelWidth(106 * mm);
            if (result_printing != 0) { showError("PTK_SetLabelWidth", result_printing); return; }

            /*打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(offset_X + 25), (uint)(offset_Y + 3), 4, 1133);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /*打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(offset_X + 27), (uint)(offset_Y + 252), 1191, 4);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /*打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(offset_X + 27), (uint)(offset_Y + 383), 1191, 4);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /*打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(offset_X + 27), (uint)(offset_Y + 639), 1190, 4);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /*打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(offset_X + 28), (uint)(offset_Y + 1027), 1190, 4);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /*打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(offset_X + 28), (uint)(offset_Y + 530), 860, 4);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /*打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(offset_X + 30), (uint)(offset_Y + 759), 1187, 4);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /*打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(offset_X + 27), (uint)(offset_Y + 943), 1193, 4);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /*打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(offset_X + 28), (uint)(offset_Y + 1078), 1189, 4);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /*打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(offset_X + 456), (uint)(offset_Y + 945), 4, 134);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /*打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(offset_X + 672), (uint)(offset_Y + 947), 4, 135);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /*打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(offset_X + 912), (uint)(offset_Y + 947), 4, 134);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /*打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(offset_X + 27), (uint)(offset_Y + 2), 1190, 4);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /*打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(offset_X + 508), (uint)(offset_Y + 124), 4, 130);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /*打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(offset_X + 755), (uint)(offset_Y + 120), 4, 134);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /*打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(offset_X + 26), (uint)(offset_Y + 322), 859, 4);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /*打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(offset_X + 27), (uint)(offset_Y + 454), 860, 4);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /*打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(offset_X + 28), (uint)(offset_Y + 589), 1190, 4);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /*打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(offset_X + 886), (uint)(offset_Y + 254), 4, 334);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /*打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(offset_X + 27), (uint)(offset_Y + 688), 1191, 4);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /*打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(offset_X + 304), (uint)(offset_Y + 2), 4, 382);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /*打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(offset_X + 417), (uint)(offset_Y + 384), 4, 558);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /*打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(offset_X + 25), (uint)(offset_Y + 852), 1192, 4);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /*打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(offset_X + 236), (uint)(offset_Y + 947), 4, 188);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /*打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(offset_X + 27), (uint)(offset_Y + 121), 1190, 4);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /*打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(offset_X + 1216), (uint)(offset_Y + 4), 4, 1133);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /*打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(offset_X + 27), (uint)(offset_Y + 1136), 1191, 4);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /*打印一维码*/
            result_printing = PrintLab.PTK_DrawBarcode((uint)(offset_X + 574), (uint)(offset_Y + 867), 0, "1", 2, 6, 40, 'N', E_UTF8("13E1028BTS0002649"));
            if (result_printing != 0) { showError("PTK_DrawBarcode", result_printing); return; }

            /*打印一维码*/
            result_printing = PrintLab.PTK_DrawBarcode((uint)(offset_X + 649), (uint)(offset_Y + 776), 0, "E30", 3, 9, 45, 'N', E_UTF8("693303722555"));
            if (result_printing != 0) { showError("PTK_DrawBarcode", result_printing); return; }

            /*打印条码下方文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 649), (uint)(offset_Y + 776 + 45 + 2), 30, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("693303722555"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印一维码*/
            result_printing = PrintLab.PTK_DrawBarcode((uint)(offset_X + 638), (uint)(offset_Y + 700), 0, "UA0", 3, 9, 40, 'N', E_UTF8("19028010145"));
            if (result_printing != 0) { showError("PTK_DrawBarcode", result_printing); return; }

            /*打印条码下方文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 638), (uint)(offset_Y + 700 + 40), 25, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("19028010145"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 107), (uint)(offset_Y + 149), 30, 0, E_UTF8("微软雅黑"), 1, 400, false, false, false, E_UTF8("产品型号"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 69), (uint)(offset_Y + 194), 30, 0, E_UTF8("微软雅黑"), 1, 400, false, false, false, E_UTF8("Product Code"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 351), (uint)(offset_Y + 175), 30, 0, E_UTF8("微软雅黑"), 1, 400, false, false, false, E_UTF8("E1088BT"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 566), (uint)(offset_Y + 149), 30, 0, E_UTF8("微软雅黑"), 1, 400, false, false, false, E_UTF8("产品名称"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 535), (uint)(offset_Y + 194), 30, 0, E_UTF8("微软雅黑"), 1, 400, false, false, false, E_UTF8("Product Name"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 791), (uint)(offset_Y + 149), 30, 0, E_UTF8("微软雅黑"), 1, 400, false, false, false, E_UTF8("1MORE Piston Fit Bluetooth "));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 103), (uint)(offset_Y + 1081), 25, 0, E_UTF8("微软雅黑"), 1, 400, false, false, false, E_UTF8("备注"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 69), (uint)(offset_Y + 1104), 33, 0, E_UTF8("微软雅黑"), 1, 400, false, false, false, E_UTF8("Remark"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 59), (uint)(offset_Y + 269), 30, 0, E_UTF8("微软雅黑"), 1, 400, false, false, false, E_UTF8("采购订单号/PO"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 65), (uint)(offset_Y + 332), 30, 0, E_UTF8("微软雅黑"), 1, 400, false, false, false, E_UTF8("包装规格/Q'ty"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 463), (uint)(offset_Y + 333), 30, 0, E_UTF8("微软雅黑"), 1, 400, false, false, false, E_UTF8("  60PCS/箱"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 950), (uint)(offset_Y + 321), 30, 0, E_UTF8("微软雅黑"), 1, 400, false, false, false, E_UTF8("Product Color"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 76), (uint)(offset_Y + 400), 30, 0, E_UTF8("微软雅黑"), 1, 400, false, false, false, E_UTF8("产品料号/PN"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 54), (uint)(offset_Y + 469), 30, 0, E_UTF8("微软雅黑"), 1, 400, false, false, false, E_UTF8("外尺寸Size(cm*cm*cm)"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 55), (uint)(offset_Y + 540), 30, 0, E_UTF8("微软雅黑"), 1, 400, false, false, false, E_UTF8("检验员/Inspector"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 58), (uint)(offset_Y + 596), 30, 0, E_UTF8("微软雅黑"), 1, 400, false, false, false, E_UTF8("检验批次/Lot NO."));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 47), (uint)(offset_Y + 645), 30, 0, E_UTF8("微软雅黑"), 1, 400, false, false, false, E_UTF8("出厂日期/Ex-factory Date"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 146), (uint)(offset_Y + 702), 30, 0, E_UTF8("微软雅黑"), 1, 400, false, false, false, E_UTF8("UPC code"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 153), (uint)(offset_Y + 767), 30, 0, E_UTF8("微软雅黑"), 1, 400, false, false, false, E_UTF8("商品条码"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 94), (uint)(offset_Y + 804), 30, 0, E_UTF8("微软雅黑"), 1, 400, false, false, false, E_UTF8("Commercial Code"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 185), (uint)(offset_Y + 862), 30, 0, E_UTF8("微软雅黑"), 1, 400, false, false, false, E_UTF8("箱号"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 94), (uint)(offset_Y + 903), 30, 0, E_UTF8("微软雅黑"), 1, 400, false, false, false, E_UTF8("Commodity Code"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 65), (uint)(offset_Y + 953), 30, 0, E_UTF8("微软雅黑"), 1, 400, false, false, false, E_UTF8("毛重（Kg)"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 96), (uint)(offset_Y + 986), 30, 0, E_UTF8("微软雅黑"), 1, 400, false, false, false, E_UTF8("G.W"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 278), (uint)(offset_Y + 953), 30, 0, E_UTF8("微软雅黑"), 1, 400, false, false, false, E_UTF8("净重（Kg）"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 495), (uint)(offset_Y + 953), 30, 0, E_UTF8("微软雅黑"), 1, 400, false, false, false, E_UTF8("体积（m3)"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 535), (uint)(offset_Y + 986), 30, 0, E_UTF8("微软雅黑"), 1, 400, false, false, false, E_UTF8("Bulk"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 324), (uint)(offset_Y + 986), 30, 0, E_UTF8("微软雅黑"), 1, 400, false, false, false, E_UTF8("N.W."));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 748), (uint)(offset_Y + 950), 30, 0, E_UTF8("微软雅黑"), 1, 400, false, false, false, E_UTF8("目的地"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 714), (uint)(offset_Y + 986), 30, 0, E_UTF8("微软雅黑"), 1, 400, false, false, false, E_UTF8("Destination "));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 1026), (uint)(offset_Y + 950), 30, 0, E_UTF8("微软雅黑"), 1, 400, false, false, false, E_UTF8("仓库"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 977), (uint)(offset_Y + 986), 30, 0, E_UTF8("微软雅黑"), 1, 400, false, false, false, E_UTF8("Warehouse"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 568), (uint)(offset_Y + 14), 42, 0, E_UTF8("微软雅黑"), 1, 400, false, false, false, E_UTF8("测试声学科技有限公司"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 448), (uint)(offset_Y + 62), 38, 0, E_UTF8("微软雅黑"), 1, 400, false, false, false, E_UTF8("TEST Acoustic Technology Limited"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 539), (uint)(offset_Y + 400), 30, 0, E_UTF8("微软雅黑"), 1, 400, false, false, false, E_UTF8("9900100514-1"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 530), (uint)(offset_Y + 476), 30, 0, E_UTF8("微软雅黑"), 1, 400, false, false, false, E_UTF8("51.5*36.0*43.5cm"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 646), (uint)(offset_Y + 907), 29, 0, E_UTF8("微软雅黑"), 1, 400, false, false, false, E_UTF8("13E1028BTS0002649"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 793), (uint)(offset_Y + 194), 30, 0, E_UTF8("微软雅黑"), 1, 400, false, false, false, E_UTF8("In-ear Headphones "));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 540), (uint)(offset_Y + 1037), 30, 0, E_UTF8("微软雅黑"), 1, 400, false, false, false, E_UTF8("0.08"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 950), (uint)(offset_Y + 477), 30, 0, E_UTF8("微软雅黑"), 1, 400, false, false, false, E_UTF8("钛色/Titanium"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 552), (uint)(offset_Y + 542), 30, 0, E_UTF8("微软雅黑"), 1, 400, false, false, false, E_UTF8("youfang Duan"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 985), (uint)(offset_Y + 280), 30, 0, E_UTF8("微软雅黑"), 1, 400, false, false, false, E_UTF8("产品颜色"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 81), (uint)(offset_Y + 1036), 29, 0, E_UTF8("微软雅黑"), 1, 400, false, false, false, E_UTF8("12.00"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 311), (uint)(offset_Y + 1036), 29, 0, E_UTF8("微软雅黑"), 1, 400, false, false, false, E_UTF8("10.65"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }


            /*打印，必须要执行这一行，否则不会打印，打印多张标签时每张标签后面都需要加它*/
            result_printing = PrintLab.PTK_PrintLabel(1, 1);
            if (result_printing != 0) { showError("PTK_PrintLabel", result_printing); return; }



            /*断开打印机连接*/
            PrintLab.PTK_CloseConnect();


            MessageBox.Show("执行成功！");
        }

        private void NameplateLabelWithForm_Click(object sender, EventArgs e)
        {
            /*
             *mm:点，毫米转为点，由打印机分辨率决定
             * 打印机分辨DPI=203时， mm=8
             * 打印机分辨DPI=300时， mm=12
             * 打印机分辨DPI=600时， mm=24
             */
            uint mm = 12;

            int result = 0;
            var message = "";

            /*连接打印机*/
            result = PrintLab.PTK_Connect_Timer(IPAddress, port, 2);
            if (result != 0)
            {
                result = getErrorInformation(result, out message);
                MessageBox.Show(message);
                return;
            }

            /*函数返回值*/
            int result_printing = 0;
            /*横坐标偏移,设置标签整体横向移动位置*/
            int offset_X = 0;

            /*纵坐标偏移，设置标签整体纵向移动位置*/
            int offset_Y = 0;

            /*获取打印机状态*/
            int[] status_Net = new int[4];
            String PrinterStatus = "";
            result_printing = PrintLab.PTK_FeedBack();
            if (result_printing != 0) { showError("PTK_FeedBack", result_printing); return; }

            result_printing = PrintLab.PTK_ReadData(status_Net, 4);
            if (result_printing != 0) { showError("PTK_ReadData", result_printing); return; }

            PrinterStatus = status_Net[0] + "";

            if (!PrinterStatus.Equals("0") && !PrinterStatus.Equals("4"))
            {
                PrintLab.PTK_CloseConnect();
                MessageBox.Show("打印机未就绪，当前错误报告：" + Status_Explain(PrinterStatus));

                return;
            }


            /*清空缓存*/
            result_printing = PrintLab.PTK_ClearBuffer();
            if (result_printing != 0) { showError("PTK_ClearBuffer", result_printing); return; }

            /*设置打印黑度 取值范围 0-20*/
            result_printing = PrintLab.PTK_SetDarkness(10);
            if (result_printing != 0) { showError("PTK_SetDarkness", result_printing); return; }

            /*设置打印速度*/
            result_printing = PrintLab.PTK_SetPrintSpeed(4);
            if (result_printing != 0) { showError("PTK_SetPrintSpeed", result_printing); return; }

            /*设置打印方向*/
            result_printing = PrintLab.PTK_SetDirection('B');
            if (result_printing != 0) { showError("PTK_SetDirection", result_printing); return; }

            /*设置标签高度、间隙及偏移 */
            result_printing = PrintLab.PTK_SetLabelHeight(30 * mm, 24, 0, false);
            if (result_printing != 0) { showError("PTK_SetLabelHeight", result_printing); return; }

            /*设置标签宽度，一定要准确，否则会导致打印内容位置不准确*/
            result_printing = PrintLab.PTK_SetLabelWidth(90 * mm);
            if (result_printing != 0) { showError("PTK_SetLabelWidth", result_printing); return; }

            /*打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(offset_X + 20), (uint)(offset_Y + 96), 1026, 4);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /*打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(offset_X + 20), (uint)(offset_Y + 170), 1025, 4);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /*打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(offset_X + 531), (uint)(offset_Y + 98), 4, 216);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /*打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(offset_X + 22), (uint)(offset_Y + 242), 1026, 4);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /*打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(offset_X + 21), (uint)(offset_Y + 312), 1026, 4);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /*打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(offset_X + 244), (uint)(offset_Y + 171), 4, 143);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /*打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(offset_X + 1044), (uint)(offset_Y + 98), 4, 216);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /*打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(offset_X + 18), (uint)(offset_Y + 98), 4, 217);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 353), (uint)(offset_Y + 12), 75, 0, E_UTF8("方正舒体"), 1, 800, false, false, false, E_UTF8("DONGSHAN"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 574), (uint)(offset_Y + 191), 33, 0, E_UTF8("Arial"), 1, 800, false, false, false, E_UTF8("ISO9001-2019"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 32), (uint)(offset_Y + 187), 33, 0, E_UTF8("Arial"), 1, 800, false, false, false, E_UTF8("Pn：1.8kW"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 298), (uint)(offset_Y + 184), 33, 0, E_UTF8("Arial"), 1, 800, false, false, false, E_UTF8("Tn：6N·m"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 572), (uint)(offset_Y + 115), 44, 0, E_UTF8("Arial"), 1, 800, false, false, false, E_UTF8("AC SERVO MOTOR"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 32), (uint)(offset_Y + 257), 33, 0, E_UTF8("Arial"), 1, 800, false, false, false, E_UTF8("Un：220V"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 306), (uint)(offset_Y + 254), 33, 0, E_UTF8("Arial"), 1, 800, false, false, false, E_UTF8("In：7A"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 575), (uint)(offset_Y + 256), 33, 0, E_UTF8("Arial"), 1, 800, false, false, false, E_UTF8("S/N:W112012161251"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 29), (uint)(offset_Y + 115), 42, 0, E_UTF8("Arial"), 1, 800, false, false, false, E_UTF8("TYPE：110ST-M04030D0"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }


            /*打印，必须要执行这一行，否则不会打印，打印多张标签时每张标签后面都需要加它*/
            result_printing = PrintLab.PTK_PrintLabel(1, 1);
            if (result_printing != 0) { showError("PTK_PrintLabel", result_printing); return; }



            /*断开打印机连接*/
            PrintLab.PTK_CloseConnect();


            MessageBox.Show("执行成功！");
        }

        private void Pass_Click(object sender, EventArgs e)
        {
            /*
             *mm:点，毫米转为点，由打印机分辨率决定
             * 打印机分辨DPI=203时， mm=8
             * 打印机分辨DPI=300时， mm=12
             * 打印机分辨DPI=600时， mm=24
             */
            uint mm = 12;

            int result = 0;
            var message = "";

            /*连接打印机*/
            result = PrintLab.PTK_Connect_Timer(IPAddress, port, 2);
            if (result != 0)
            {
                result = getErrorInformation(result, out message);
                MessageBox.Show(message);
                return;
            }

            /*函数返回值*/
            int result_printing = 0;
            /*横坐标偏移,设置标签整体横向移动位置*/
            int offset_X = 0;

            /*纵坐标偏移，设置标签整体纵向移动位置*/
            int offset_Y = 0;


            /*获取打印机状态*/
            int[] status_Net = new int[4];
            String PrinterStatus = "";
            result_printing = PrintLab.PTK_FeedBack();
            if (result_printing != 0) { showError("PTK_FeedBack", result_printing); return; }

            result_printing = PrintLab.PTK_ReadData(status_Net, 4);
            if (result_printing != 0) { showError("PTK_ReadData", result_printing); return; }

            PrinterStatus = status_Net[0] + "";

            if (!PrinterStatus.Equals("0") && !PrinterStatus.Equals("4"))
            {
                PrintLab.PTK_CloseConnect();
                MessageBox.Show("打印机未就绪，当前错误报告：" + Status_Explain(PrinterStatus));

                return;
            }


            /*清空缓存*/
            result_printing = PrintLab.PTK_ClearBuffer();
            if (result_printing != 0) { showError("PTK_ClearBuffer", result_printing); return; }

            /*设置打印黑度 取值范围 0-20*/
            result_printing = PrintLab.PTK_SetDarkness(10);
            if (result_printing != 0) { showError("PTK_SetDarkness", result_printing); return; }

            /*设置打印速度*/
            result_printing = PrintLab.PTK_SetPrintSpeed(4);
            if (result_printing != 0) { showError("PTK_SetPrintSpeed", result_printing); return; }

            /*设置打印方向*/
            result_printing = PrintLab.PTK_SetDirection('B');
            if (result_printing != 0) { showError("PTK_SetDirection", result_printing); return; }

            /*设置标签高度、间隙及偏移 */
            result_printing = PrintLab.PTK_SetLabelHeight(88 * mm, 24, 0, false);
            if (result_printing != 0) { showError("PTK_SetLabelHeight", result_printing); return; }

            /*设置标签宽度，一定要准确，否则会导致打印内容位置不准确*/
            result_printing = PrintLab.PTK_SetLabelWidth(60 * mm);
            if (result_printing != 0) { showError("PTK_SetLabelWidth", result_printing); return; }

            /*打印二维码*/
            result_printing = PrintLab.PTK_DrawBar2D_QR((uint)(offset_X + 216), (uint)(offset_Y + 401), 0, 0, 0, 5, 4, 1, 8, E_UTF8("IOTE 2021第十六届国际物联网展   ·  深圳站8月18-20日 深圳会展中心（福田）参展人：高大参展单位：深圳市博思得科技发展有限公司"));
            if (result_printing != 0) { showError("PTK_DrawBar2D_QR", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 258), (uint)(offset_Y + 309), 67, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("参会证"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 90), (uint)(offset_Y + 188), 50, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("国际物联网展   ·  深圳站"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 85), (uint)(offset_Y + 78), 83, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("IOTE 2021"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 486), (uint)(offset_Y + 112), 38, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("第十六届"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 54), (uint)(offset_Y + 838), 46, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("8月18-20日 深圳会展中心（福田）"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 54), (uint)(offset_Y + 711), 33, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("参展人：高大"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 54), (uint)(offset_Y + 769), 33, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("参展单位：深圳市博思得科技发展有限公司"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*写RFID数据 具体参数请查看文档 写数据之前确保RFID标签已经校准成功*/
            result_printing = PrintLab.PTK_RWRFIDLabel(1, 0, 0, 4, 1, "20210818");
            if (result_printing != 0) { showError("PTK_RWRFIDLabel", result_printing); return; }

            /*打印，必须要执行这一行，否则不会打印，打印多张标签时每张标签后面都需要加它*/
            result_printing = PrintLab.PTK_PrintLabel(1, 1);
            if (result_printing != 0) { showError("PTK_PrintLabel", result_printing); return; }



            /*断开打印机连接*/
            PrintLab.PTK_CloseConnect();


            MessageBox.Show("执行成功！");
        }

        private void Fixed_Assets_RFID_Click(object sender, EventArgs e)
        {
            /*
             *mm:点，毫米转为点，由打印机分辨率决定
             * 打印机分辨DPI=203时， mm=8
             * 打印机分辨DPI=300时， mm=12
             * 打印机分辨DPI=600时， mm=24
             */
            uint mm = 12;

            int result = 0;
            var message = "";

            /*连接打印机*/
            result = PrintLab.PTK_Connect_Timer(IPAddress, port, 2);
            if (result != 0)
            {
                result = getErrorInformation(result, out message);
                MessageBox.Show(message);
                return;
            }

            /*函数返回值*/
            int result_printing = 0;
            /*横坐标偏移,设置标签整体横向移动位置*/
            int offset_X = 0;

            /*纵坐标偏移，设置标签整体纵向移动位置*/
            int offset_Y = 0;


            /*获取打印机状态*/
            int[] status_Net = new int[4];
            String PrinterStatus = "";
            result_printing = PrintLab.PTK_FeedBack();
            if (result_printing != 0) { showError("PTK_FeedBack", result_printing); return; }

            result_printing = PrintLab.PTK_ReadData(status_Net, 4);
            if (result_printing != 0) { showError("PTK_ReadData", result_printing); return; }

            PrinterStatus = status_Net[0] + "";

            if (!PrinterStatus.Equals("0") && !PrinterStatus.Equals("4"))
            {
                PrintLab.PTK_CloseConnect();
                MessageBox.Show("打印机未就绪，当前错误报告：" + Status_Explain(PrinterStatus));

                return;
            }


            /*清空缓存*/
            result_printing = PrintLab.PTK_ClearBuffer();
            if (result_printing != 0) { showError("PTK_ClearBuffer", result_printing); return; }

            /*设置打印黑度 取值范围 0-20*/
            result_printing = PrintLab.PTK_SetDarkness(10);
            if (result_printing != 0) { showError("PTK_SetDarkness", result_printing); return; }

            /*设置打印速度*/
            result_printing = PrintLab.PTK_SetPrintSpeed(4);
            if (result_printing != 0) { showError("PTK_SetPrintSpeed", result_printing); return; }

            /*设置打印方向*/
            result_printing = PrintLab.PTK_SetDirection('B');
            if (result_printing != 0) { showError("PTK_SetDirection", result_printing); return; }

            /*设置标签高度、间隙及偏移 */
            result_printing = PrintLab.PTK_SetLabelHeight(18 * mm, 24, 0, false);
            if (result_printing != 0) { showError("PTK_SetLabelHeight", result_printing); return; }

            /*设置标签宽度，一定要准确，否则会导致打印内容位置不准确*/
            result_printing = PrintLab.PTK_SetLabelWidth(70 * mm);
            if (result_printing != 0) { showError("PTK_SetLabelWidth", result_printing); return; }

            /*打印矩形*/
            result_printing = PrintLab.PTK_DrawRectangle((uint)(offset_X + 23), (uint)(offset_Y + 5), 4, 817, 204);
            if (result_printing != 0) { showError("PTK_DrawRectangle", result_printing); return; }

            /*打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(offset_X + 24), (uint)(offset_Y + 51), 791, 4);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /*打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(offset_X + 25), (uint)(offset_Y + 87), 791, 4);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /*打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(offset_X + 24), (uint)(offset_Y + 126), 791, 4);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /*打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(offset_X + 24), (uint)(offset_Y + 163), 359, 4);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /*打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(offset_X + 381), (uint)(offset_Y + 51), 4, 151);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /*打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(offset_X + 573), (uint)(offset_Y + 52), 4, 77);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /*打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(offset_X + 171), (uint)(offset_Y + 53), 4, 150);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 286), (uint)(offset_Y + 6), 44, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("资产管理中心"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 54), (uint)(offset_Y + 57), 25, 0, E_UTF8("黑体"), 1, 400, false, false, false, E_UTF8("使用部门"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 227), (uint)(offset_Y + 57), 25, 0, E_UTF8("黑体"), 1, 400, false, false, false, E_UTF8("财务部"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 54), (uint)(offset_Y + 94), 25, 0, E_UTF8("黑体"), 1, 400, false, false, false, E_UTF8("资产编号"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 54), (uint)(offset_Y + 133), 25, 0, E_UTF8("黑体"), 1, 400, false, false, false, E_UTF8("购买时间"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 54), (uint)(offset_Y + 168), 25, 0, E_UTF8("黑体"), 1, 400, false, false, false, E_UTF8("启用时间"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 426), (uint)(offset_Y + 61), 25, 0, E_UTF8("黑体"), 1, 400, false, false, false, E_UTF8("资产类型"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 217), (uint)(offset_Y + 97), 25, 0, E_UTF8("黑体"), 1, 400, false, false, false, E_UTF8("A01252951"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 431), (uint)(offset_Y + 97), 25, 0, E_UTF8("黑体"), 1, 400, false, false, false, E_UTF8("资产名称"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 624), (uint)(offset_Y + 95), 25, 0, E_UTF8("黑体"), 1, 400, false, false, false, E_UTF8("彩色打印机"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 210), (uint)(offset_Y + 133), 25, 0, E_UTF8("黑体"), 1, 400, false, false, false, E_UTF8("2021-07-22"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 210), (uint)(offset_Y + 170), 25, 0, E_UTF8("黑体"), 1, 400, false, false, false, E_UTF8("2021-07-29"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 624), (uint)(offset_Y + 57), 25, 0, E_UTF8("黑体"), 1, 400, false, false, false, E_UTF8("办公用品"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 429), (uint)(offset_Y + 148), 25, 0, E_UTF8("黑体"), 1, 400, false, false, false, E_UTF8("使用人与保管人：王二"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*写RFID数据 具体参数请查看文档 写数据之前确保RFID标签已经校准成功*/
            result_printing = PrintLab.PTK_RWRFIDLabel(1, 0, 0, 4, 1, "12345706");
            if (result_printing != 0) { showError("PTK_RWRFIDLabel", result_printing); return; }

            /*打印，必须要执行这一行，否则不会打印，打印多张标签时每张标签后面都需要加它*/
            result_printing = PrintLab.PTK_PrintLabel(1, 1);
            if (result_printing != 0) { showError("PTK_PrintLabel", result_printing); return; }



            /*断开打印机连接*/
            PrintLab.PTK_CloseConnect();


            MessageBox.Show("执行成功！");
        }

        private void Clothing_Tag_RFID_Click(object sender, EventArgs e)
        {
            /*
             *mm:点，毫米转为点，由打印机分辨率决定
             * 打印机分辨DPI=203时， mm=8
             * 打印机分辨DPI=300时， mm=12
             * 打印机分辨DPI=600时， mm=24
             */
            uint mm = 12;

            int result = 0;
            var message = "";

            /*连接打印机*/
            result = PrintLab.PTK_Connect_Timer(IPAddress, port, 2);
            if (result != 0)
            {
                result = getErrorInformation(result, out message);
                MessageBox.Show(message);
                return;
            }

            /*函数返回值*/
            int result_printing = 0;
            /*横坐标偏移,设置标签整体横向移动位置*/
            int offset_X = 0;

            /*纵坐标偏移，设置标签整体纵向移动位置*/
            int offset_Y = 0;


            /*获取打印机状态*/
            int[] status_Net = new int[4];
            String PrinterStatus = "";
            result_printing = PrintLab.PTK_FeedBack();
            if (result_printing != 0) { showError("PTK_FeedBack", result_printing); return; }

            result_printing = PrintLab.PTK_ReadData(status_Net, 4);
            if (result_printing != 0) { showError("PTK_ReadData", result_printing); return; }

            PrinterStatus = status_Net[0] + "";

            if (!PrinterStatus.Equals("0") && !PrinterStatus.Equals("4"))
            {
                PrintLab.PTK_CloseConnect();
                MessageBox.Show("打印机未就绪，当前错误报告：" + Status_Explain(PrinterStatus));

                return;
            }


            /*清空缓存*/
            result_printing = PrintLab.PTK_ClearBuffer();
            if (result_printing != 0) { showError("PTK_ClearBuffer", result_printing); return; }

            /*设置打印黑度 取值范围 0-20*/
            result_printing = PrintLab.PTK_SetDarkness(10);
            if (result_printing != 0) { showError("PTK_SetDarkness", result_printing); return; }

            /*设置打印速度*/
            result_printing = PrintLab.PTK_SetPrintSpeed(4);
            if (result_printing != 0) { showError("PTK_SetPrintSpeed", result_printing); return; }

            /*设置打印方向*/
            result_printing = PrintLab.PTK_SetDirection('B');
            if (result_printing != 0) { showError("PTK_SetDirection", result_printing); return; }

            /*设置标签高度、间隙及偏移 */
            result_printing = PrintLab.PTK_SetLabelHeight(85 * mm, 24, 0, false);
            if (result_printing != 0) { showError("PTK_SetLabelHeight", result_printing); return; }

            /*设置标签宽度，一定要准确，否则会导致打印内容位置不准确*/
            result_printing = PrintLab.PTK_SetLabelWidth(40 * mm);
            if (result_printing != 0) { showError("PTK_SetLabelWidth", result_printing); return; }

            /*打印本地图片*/
            result_printing = PrintLab.PTK_AnyGraphicsPrint((uint)(offset_X + 44), (uint)(offset_Y + 670), "DoNotBleach", CurrentDirectory + "\\logo\\DoNotBleach.bmp", 0.16f, 92, 74, 0);
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印本地图片*/
            result_printing = PrintLab.PTK_AnyGraphicsPrint((uint)(offset_X + 44), (uint)(offset_Y + 730), "DFITS", CurrentDirectory + "\\logo\\DFITS.bmp", 0.16f, 92, 74, 0);
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印本地图片*/
            result_printing = PrintLab.PTK_AnyGraphicsPrint((uint)(offset_X + 44), (uint)(offset_Y + 799), "VW30", CurrentDirectory + "\\logo\\VW30.bmp", 0.18f, 92, 74, 0);
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 168), (uint)(offset_Y + 25), 44, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("合格证"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 39), (uint)(offset_Y + 81), 38, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("品名：女装T"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 39), (uint)(offset_Y + 133), 38, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("颜色：淡蓝"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 36), (uint)(offset_Y + 187), 38, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("号型：S"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 39), (uint)(offset_Y + 241), 38, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("成份：100%棉"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 38), (uint)(offset_Y + 296), 38, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("执行标准："));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 38), (uint)(offset_Y + 334), 38, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("GB/T22849-2212"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 34), (uint)(offset_Y + 536), 40, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("等级：一级  检验：01"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 35), (uint)(offset_Y + 602), 38, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("洗涤方法："));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 107), (uint)(offset_Y + 805), 38, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("30°C以下水洗"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 112), (uint)(offset_Y + 668), 38, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("不可漂洗"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 114), (uint)(offset_Y + 730), 38, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("阴凉处平摊晾干"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*写RFID数据 具体参数请查看文档 写数据之前确保RFID标签已经校准成功*/
            result_printing = PrintLab.PTK_RWRFIDLabel(1, 0, 0, 4, 1, "20160830");
            if (result_printing != 0) { showError("PTK_RWRFIDLabel", result_printing); return; }

            /*打印，必须要执行这一行，否则不会打印，打印多张标签时每张标签后面都需要加它*/
            result_printing = PrintLab.PTK_PrintLabel(1, 1);
            if (result_printing != 0) { showError("PTK_PrintLabel", result_printing); return; }



            /*断开打印机连接*/
            PrintLab.PTK_CloseConnect();


            MessageBox.Show("执行成功！");
        }

        private void Jewelry_Tag_RFID_Click(object sender, EventArgs e)
        {
            /*
             *mm:点，毫米转为点，由打印机分辨率决定
             * 打印机分辨DPI=203时， mm=8
             * 打印机分辨DPI=300时， mm=12
             * 打印机分辨DPI=600时， mm=24
             */
            uint mm = 12;

            int result = 0;
            var message = "";

            /*连接打印机*/
            result = PrintLab.PTK_Connect_Timer(IPAddress, port, 2);
            if (result != 0)
            {
                result = getErrorInformation(result, out message);
                MessageBox.Show(message);
                return;
            }

            /*函数返回值*/
            int result_printing = 0;
            /*横坐标偏移,设置标签整体横向移动位置*/
            int offset_X = 0;

            /*纵坐标偏移，设置标签整体纵向移动位置*/
            int offset_Y = 0;


            /*获取打印机状态*/
            int[] status_Net = new int[4];
            String PrinterStatus = "";
            result_printing = PrintLab.PTK_FeedBack();
            if (result_printing != 0) { showError("PTK_FeedBack", result_printing); return; }

            result_printing = PrintLab.PTK_ReadData(status_Net, 4);
            if (result_printing != 0) { showError("PTK_ReadData", result_printing); return; }

            PrinterStatus = status_Net[0] + "";

            if (!PrinterStatus.Equals("0") && !PrinterStatus.Equals("4"))
            {
                PrintLab.PTK_CloseConnect();
                MessageBox.Show("打印机未就绪，当前错误报告：" + Status_Explain(PrinterStatus));

                return;
            }


            /*清空缓存*/
            result_printing = PrintLab.PTK_ClearBuffer();
            if (result_printing != 0) { showError("PTK_ClearBuffer", result_printing); return; }

            /*设置打印黑度 取值范围 0-20*/
            result_printing = PrintLab.PTK_SetDarkness(10);
            if (result_printing != 0) { showError("PTK_SetDarkness", result_printing); return; }

            /*设置打印速度*/
            result_printing = PrintLab.PTK_SetPrintSpeed(4);
            if (result_printing != 0) { showError("PTK_SetPrintSpeed", result_printing); return; }

            /*设置打印方向*/
            result_printing = PrintLab.PTK_SetDirection('B');
            if (result_printing != 0) { showError("PTK_SetDirection", result_printing); return; }

            /*设置标签高度、间隙及偏移 */
            result_printing = PrintLab.PTK_SetLabelHeight(28 * mm, 24, 0, false);
            if (result_printing != 0) { showError("PTK_SetLabelHeight", result_printing); return; }

            /*设置标签宽度，一定要准确，否则会导致打印内容位置不准确*/
            result_printing = PrintLab.PTK_SetLabelWidth(76 * mm);
            if (result_printing != 0) { showError("PTK_SetLabelWidth", result_printing); return; }

            /*打印一维码*/
            result_printing = PrintLab.PTK_DrawBarcode((uint)(offset_X + 319), (uint)(offset_Y + 31), 1, "1", 2, 6, 68, 'N', E_UTF8("TKFPAE039"));
            if (result_printing != 0) { showError("PTK_DrawBarcode", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 347), (uint)(offset_Y + 67), 21, 0, E_UTF8("Arial"), 2, 400, false, false, false, E_UTF8("证书号：TKFPAE039"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 243), (uint)(offset_Y + 118), 25, 0, E_UTF8("Arial"), 2, 400, false, false, false, E_UTF8("00000018"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 176), (uint)(offset_Y + 50), 38, 0, E_UTF8("Arial"), 2, 400, false, false, false, E_UTF8("18K金钻石戒指"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 125), (uint)(offset_Y + 57), 17, 0, E_UTF8("Arial"), 2, 400, false, false, false, E_UTF8("金：3.56g    石：0.01ct   WS 12#"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 87), (uint)(offset_Y + 96), 33, 0, E_UTF8("Arial"), 2, 400, false, false, false, E_UTF8("￥:5623.00"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*写RFID数据 具体参数请查看文档 写数据之前确保RFID标签已经校准成功*/
            result_printing = PrintLab.PTK_RWRFIDLabel(1, 1, 0, 9, 1, "TKFPAE039");
            if (result_printing != 0) { showError("PTK_RWRFIDLabel", result_printing); return; }

            /*打印，必须要执行这一行，否则不会打印，打印多张标签时每张标签后面都需要加它*/
            result_printing = PrintLab.PTK_PrintLabel(1, 1);
            if (result_printing != 0) { showError("PTK_PrintLabel", result_printing); return; }



            /*断开打印机连接*/
            PrintLab.PTK_CloseConnect();


            MessageBox.Show("执行成功！");
        }

        private void Wristband_RFID_Click(object sender, EventArgs e)
        {
            /*
             *mm:点，毫米转为点，由打印机分辨率决定
             * 打印机分辨DPI=203时， mm=8
             * 打印机分辨DPI=300时， mm=12
             * 打印机分辨DPI=600时， mm=24
             */
            uint mm = 12;

            int result = 0;
            var message = "";

            /*连接打印机*/
            result = PrintLab.PTK_Connect_Timer(IPAddress, port, 2);
            if (result != 0)
            {
                result = getErrorInformation(result, out message);
                MessageBox.Show(message);
                return;
            }

            /*函数返回值*/
            int result_printing = 0;
            /*横坐标偏移,设置标签整体横向移动位置*/
            int offset_X = 0;

            /*纵坐标偏移，设置标签整体纵向移动位置*/
            int offset_Y = 0;


            /*获取打印机状态*/
            int[] status_Net = new int[4];
            String PrinterStatus = "";
            result_printing = PrintLab.PTK_FeedBack();
            if (result_printing != 0) { showError("PTK_FeedBack", result_printing); return; }

            result_printing = PrintLab.PTK_ReadData(status_Net, 4);
            if (result_printing != 0) { showError("PTK_ReadData", result_printing); return; }

            PrinterStatus = status_Net[0] + "";

            if (!PrinterStatus.Equals("0") && !PrinterStatus.Equals("4"))
            {
                PrintLab.PTK_CloseConnect();
                MessageBox.Show("打印机未就绪，当前错误报告：" + Status_Explain(PrinterStatus));

                return;
            }


            /*清空缓存*/
            result_printing = PrintLab.PTK_ClearBuffer();
            if (result_printing != 0) { showError("PTK_ClearBuffer", result_printing); return; }

            /*设置打印黑度 取值范围 0-20*/
            result_printing = PrintLab.PTK_SetDarkness(10);
            if (result_printing != 0) { showError("PTK_SetDarkness", result_printing); return; }

            /*设置打印速度*/
            result_printing = PrintLab.PTK_SetPrintSpeed(4);
            if (result_printing != 0) { showError("PTK_SetPrintSpeed", result_printing); return; }

            /*设置打印方向*/
            result_printing = PrintLab.PTK_SetDirection('B');
            if (result_printing != 0) { showError("PTK_SetDirection", result_printing); return; }

            /*设置标签高度、间隙及偏移 */
            result_printing = PrintLab.PTK_SetLabelHeight(295 * mm, 24, 0, false);
            if (result_printing != 0) { showError("PTK_SetLabelHeight", result_printing); return; }

            /*设置标签宽度，一定要准确，否则会导致打印内容位置不准确*/
            result_printing = PrintLab.PTK_SetLabelWidth(32 * mm);
            if (result_printing != 0) { showError("PTK_SetLabelWidth", result_printing); return; }

            /*打印一维码*/
            result_printing = PrintLab.PTK_DrawBarcode((uint)(offset_X + 252), (uint)(offset_Y + 2302), 1, "1", 4, 12, 118, 'N', E_UTF8("130673"));
            if (result_printing != 0) { showError("PTK_DrawBarcode", result_printing); return; }

            /*打印二维码*/
            result_printing = PrintLab.PTK_DrawBar2D_QR((uint)(offset_X + 98), (uint)(offset_Y + 3015), 0, 0, 0, 6, 4, 1, 8, E_UTF8("李爱华  男  58岁神经科： 16  床住院号：  130673"));
            if (result_printing != 0) { showError("PTK_DrawBar2D_QR", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 332), (uint)(offset_Y + 2290), 57, 0, E_UTF8("Arial"), 2, 400, false, false, false, E_UTF8("广东省人民医院"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 269), (uint)(offset_Y + 2598), 42, 0, E_UTF8("Arial"), 2, 400, false, false, false, E_UTF8("李爱华  男  58岁"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 194), (uint)(offset_Y + 2598), 42, 0, E_UTF8("Arial"), 2, 400, false, false, false, E_UTF8("神经科： 16  床"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 119), (uint)(offset_Y + 2598), 42, 0, E_UTF8("Arial"), 2, 400, false, false, false, E_UTF8("住院号：  130673"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*写RFID数据 具体参数请查看文档 写数据之前确保RFID标签已经校准成功*/
            result_printing = PrintLab.PTK_RWRFIDLabel(1, 0, 0, 3, 1, "130673");
            if (result_printing != 0) { showError("PTK_RWRFIDLabel", result_printing); return; }

            /*打印，必须要执行这一行，否则不会打印，打印多张标签时每张标签后面都需要加它*/
            result_printing = PrintLab.PTK_PrintLabel(1, 1);
            if (result_printing != 0) { showError("PTK_PrintLabel", result_printing); return; }



            /*断开打印机连接*/
            PrintLab.PTK_CloseConnect();


            MessageBox.Show("执行成功！");
        }

        private void Medical_sign_Click(object sender, EventArgs e)
        {
            /*
             *mm:点，毫米转为点，由打印机分辨率决定
             * 打印机分辨DPI=203时， mm=8
             * 打印机分辨DPI=300时， mm=12
             * 打印机分辨DPI=600时， mm=24
             */
            uint mm = 12;

            int result = 0;
            var message = "";

            /*连接打印机*/
            result = PrintLab.PTK_Connect_Timer(IPAddress, port, 2);
            if (result != 0)
            {
                result = getErrorInformation(result, out message);
                MessageBox.Show(message);
                return;
            }

            /*函数返回值*/
            int result_printing = 0;
            /*横坐标偏移,设置标签整体横向移动位置*/
            int offset_X = 0;

            /*纵坐标偏移，设置标签整体纵向移动位置*/
            int offset_Y = 0;


            /*获取打印机状态*/
            int[] status_Net = new int[4];
            String PrinterStatus = "";
            result_printing = PrintLab.PTK_FeedBack();
            if (result_printing != 0) { showError("PTK_FeedBack", result_printing); return; }

            result_printing = PrintLab.PTK_ReadData(status_Net, 4);
            if (result_printing != 0) { showError("PTK_ReadData", result_printing); return; }

            PrinterStatus = status_Net[0] + "";

            if (!PrinterStatus.Equals("0") && !PrinterStatus.Equals("4"))
            {
                PrintLab.PTK_CloseConnect();
                MessageBox.Show("打印机未就绪，当前错误报告：" + Status_Explain(PrinterStatus));

                return;
            }


            /*清空缓存*/
            result_printing = PrintLab.PTK_ClearBuffer();
            if (result_printing != 0) { showError("PTK_ClearBuffer", result_printing); return; }

            /*设置打印黑度 取值范围 0-20*/
            result_printing = PrintLab.PTK_SetDarkness(10);
            if (result_printing != 0) { showError("PTK_SetDarkness", result_printing); return; }

            /*设置打印速度*/
            result_printing = PrintLab.PTK_SetPrintSpeed(4);
            if (result_printing != 0) { showError("PTK_SetPrintSpeed", result_printing); return; }

            /*设置打印方向*/
            result_printing = PrintLab.PTK_SetDirection('B');
            if (result_printing != 0) { showError("PTK_SetDirection", result_printing); return; }

            /*设置标签高度、间隙及偏移 */
            result_printing = PrintLab.PTK_SetLabelHeight(35 * mm, 24, 0, false);
            if (result_printing != 0) { showError("PTK_SetLabelHeight", result_printing); return; }

            /*设置标签宽度，一定要准确，否则会导致打印内容位置不准确*/
            result_printing = PrintLab.PTK_SetLabelWidth(90 * mm);
            if (result_printing != 0) { showError("PTK_SetLabelWidth", result_printing); return; }

            /*打印一维码*/
            result_printing = PrintLab.PTK_DrawBarcode((uint)(offset_X + 79), (uint)(offset_Y + 102), 0, "1", 4, 12, 84, 'N', E_UTF8("2000002049"));
            if (result_printing != 0) { showError("PTK_DrawBarcode", result_printing); return; }

            /*打印矩形*/
            result_printing = PrintLab.PTK_DrawRectangle((uint)(offset_X + 27), (uint)(offset_Y + 90), 4, 1036, 393);
            if (result_printing != 0) { showError("PTK_DrawRectangle", result_printing); return; }

            /*打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(offset_X + 28), (uint)(offset_Y + 241), 1008, 4);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /*打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(offset_X + 28), (uint)(offset_Y + 289), 1006, 4);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /*打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(offset_X + 153), (uint)(offset_Y + 197), 4, 193);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /*打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(offset_X + 471), (uint)(offset_Y + 93), 4, 298);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /*打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(offset_X + 472), (uint)(offset_Y + 142), 563, 4);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /*打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(offset_X + 30), (uint)(offset_Y + 195), 1004, 4);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /*打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(offset_X + 612), (uint)(offset_Y + 93), 4, 297);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /*打印线条*/
            result_printing = PrintLab.PTK_DrawLineOr((uint)(offset_X + 28), (uint)(offset_Y + 338), 1007, 4);
            if (result_printing != 0) { showError("PTK_DrawLineOr", result_printing); return; }

            /*打印本地图形*/
            result_printing = PrintLab.PTK_AnyGraphicsPrint(67, 32, "logo", CurrentDirectory + "\\logo\\logo.jpg", 0.8f, 92, 74, 0);
            if (result_printing != 0) { showError("PTK_AnyGraphicsPrint", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 672), (uint)(offset_Y + 97), 38, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("2000002049"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 673), (uint)(offset_Y + 147), 38, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("血（4ml）"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 921), (uint)(offset_Y + 147), 38, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("黄管"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 217), (uint)(offset_Y + 198), 38, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("高大"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 217), (uint)(offset_Y + 243), 38, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("女 "));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 217), (uint)(offset_Y + 294), 38, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("64岁"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 217), (uint)(offset_Y + 345), 38, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("656845987"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 673), (uint)(offset_Y + 245), 38, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("骨科一病房"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 921), (uint)(offset_Y + 248), 38, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("11床"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 673), (uint)(offset_Y + 295), 38, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("2021-07-22"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 921), (uint)(offset_Y + 294), 38, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("07:00"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 673), (uint)(offset_Y + 199), 38, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("生化室（检验科）"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 673), (uint)(offset_Y + 345), 38, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("肝全，肾全"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 49), (uint)(offset_Y + 198), 38, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("姓名"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 49), (uint)(offset_Y + 245), 38, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("性别"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 49), (uint)(offset_Y + 294), 38, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("年龄"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 49), (uint)(offset_Y + 343), 38, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("ID号"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 498), (uint)(offset_Y + 200), 38, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("科室"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 498), (uint)(offset_Y + 244), 38, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("床号"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 498), (uint)(offset_Y + 295), 38, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("日期"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 498), (uint)(offset_Y + 342), 38, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("备注"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }
            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 391), (uint)(offset_Y + 30), 49, 0, E_UTF8("楷体"), 1, 400, false, false, false, E_UTF8("北京市阳光人民医院"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 498), (uint)(offset_Y + 97), 38, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("编号"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*打印文字*/
            result_printing = PrintLab.PTK_DrawText_TrueType((uint)(offset_X + 498), (uint)(offset_Y + 150), 38, 0, E_UTF8("Arial"), 1, 400, false, false, false, E_UTF8("品名"));
            if (result_printing != 0) { showError("PTK_DrawText_TrueType", result_printing); return; }

            /*高频（HF） RFID打印设置*/
            result_printing = PrintLab.PTK_SetHFRFID('H', 0, 0);
            if (result_printing != 0) { showError("PTK_SetHFRFID", result_printing); return; }

            /*编码高频RFID数据，写数据之前确保RFID标签已经校准成功*/
            result_printing = PrintLab.PTK_RWHFLabel('W', 5, 1, "2000002049", false);
            if (result_printing != 0) { showError("PTK_RWHFLabel", result_printing); return; }

            /*打印，必须要执行这一行，否则不会打印，打印多张标签时每张标签后面都需要加它*/
            result_printing = PrintLab.PTK_PrintLabel(1, 1);
            if (result_printing != 0) { showError("PTK_PrintLabel", result_printing); return; }



            /*断开打印机连接*/
            PrintLab.PTK_CloseConnect();


            MessageBox.Show("执行成功！");
        }



        private void EndcodeHFRFID_ReturnRFIDData_Click(object sender, EventArgs e)
        {
            /*
            *mm:点，毫米转为点，由打印机分辨率决定
            * 打印机分辨DPI=203时， mm=8
            * 打印机分辨DPI=300时， mm=12
            * 打印机分辨DPI=600时， mm=24
            */
            uint mm = 12;

            int result = 0;
            var message = "";

            /*连接打印机*/
            result = PrintLab.PTK_Connect_Timer(IPAddress, port, 2);
            if (result != 0)
            {
                result = getErrorInformation(result, out message);
                MessageBox.Show(message);
                return;
            }

            byte[] data = new byte[1024];
            byte[] status = new byte[10];
            var RFIDData = "";
            var PrinterStatus = "";
            /*函数返回值*/
            int result_printing = 0;

            /*横坐标偏移,设置标签整体横向移动位置*/
            int offset_X = 0;

            /*纵坐标偏移，设置标签整体纵向移动位置*/
            int offset_Y = 0;

            /*清空缓存*/
            result_printing = PrintLab.PTK_ClearBuffer();
            if (result_printing != 0) { showError("PTK_ClearBuffer", result_printing); return; }

            /*设置打印黑度 取值范围 0-20*/
            result_printing = PrintLab.PTK_SetDarkness(10);
            if (result_printing != 0) { showError("PTK_SetDarkness", result_printing); return; }

            /*设置打印速度*/
            result_printing = PrintLab.PTK_SetPrintSpeed(4);
            if (result_printing != 0) { showError("PTK_SetPrintSpeed", result_printing); return; }

            /*设置打印方向*/
            result_printing = PrintLab.PTK_SetDirection('B');
            if (result_printing != 0) { showError("PTK_SetDirection", result_printing); return; }

            /*设置标签高度、间隙及偏移*/
            result_printing = PrintLab.PTK_SetLabelHeight(29 * mm, 24, 0, false);
            if (result_printing != 0) { showError("PTK_SetLabelHeight", result_printing); return; }

            /*设置标签宽度，一定要准确，否则会导致打印内容位置不准确*/
            result_printing = PrintLab.PTK_SetLabelWidth(59 * mm);
            if (result_printing != 0) { showError("PTK_SetLabelWidth", result_printing); return; }

            /*高频（HF） RFID打印设置*/
            result_printing = PrintLab.PTK_SetHFRFID('H', 0, 0);
            if (result_printing != 0) { showError("PTK_SetHFRFID", result_printing); return; }

            /*打印二维码 此示例为QR码 付款码就是这个码*/
            result_printing = PrintLab.PTK_DrawBar2D_QR((uint)(120 + offset_X), (uint)(48 + offset_Y), 0, 0, 0, 3, 4, 1, 8, E_UTF8("设计精湛 ABCD 1234 ^-^ @@ && $$ ￥￥"));
            if (result_printing != 0) { showError("PTK_DrawBar2D_QR", result_printing); return; }

            /*写RFID数据 具体参数请查看文档*/
            result_printing = PrintLab.PTK_RWHFLabel('W', 4, 8, "41414141395542687474703A2F2F7777772E62616964752E636F6D3F3D344544", false);
            if (result_printing != 0) { showError("PTK_RWHFLabel", result_printing); return; }

            result_printing = PrintLab.PTK_ReadHFRFIDSetting(2, 0, 5);
            if (result_printing != 0) { showError("PTK_ReadHFRFIDSetting", result_printing); return; }

            result_printing = PrintLab.PTK_PrintAndCallback(data, status);
            if (result_printing != 0) { showError("PTK_PrintAndCallback", result_printing); return; }

            RFIDData = Encoding.Default.GetString(data).Trim('\0');
            PrinterStatus = Encoding.Default.GetString(status).Trim('\0');
            Console.WriteLine(RFIDData + PrinterStatus);


            /*断开打印机连接*/
            PrintLab.PTK_CloseConnect();
            MessageBox.Show("执行成功！\r\n" + "RFIDData:" + RFIDData + "\r\nPrinterStatus:" + PrinterStatus);

        }

        private void ReadFirst_EncodeRFID_Print_job_Click(object sender, EventArgs e)
        {
            /*
             *mm:点，毫米转为点，由打印机分辨率决定
             * 打印机分辨DPI=203时， mm=8
             * 打印机分辨DPI=300时， mm=12
             * 打印机分辨DPI=600时， mm=24
             */
            uint mm = 12;

            int result = 0;
            var message = "";

            /*连接打印机*/
            result = PrintLab.PTK_Connect_Timer(IPAddress, port, 2);
            if (result != 0)
            {
                result = getErrorInformation(result, out message);
                MessageBox.Show(message);
                return;
            }


            byte[] data = new byte[1024];
            byte[] status = new byte[10];
            String RFIDData = "";
            String PrinterStatus = "";
            /*函数返回值*/
            int result_printing = 0;

            /*横坐标偏移,设置标签整体横向移动位置*/
            int offset_X = 0;

            /*纵坐标偏移，设置标签整体纵向移动位置*/
            int offset_Y = 0;


            /*获取打印机状态*/
            int[] status_Net = new int[4];
            result_printing = PrintLab.PTK_FeedBack();
            if (result_printing != 0) { showError("PTK_FeedBack", result_printing); return; }

            result_printing = PrintLab.PTK_ReadData(status_Net, 4);
            if (result_printing != 0) { showError("PTK_ReadData", result_printing); return; }

            PrinterStatus = status_Net[0] + "";

            if (!PrinterStatus.Equals("0"))
            {
                PrintLab.PTK_CloseConnect();
                MessageBox.Show("打印机未就绪，当前错误报告：" + Status_Explain(PrinterStatus));

                return;
            }

            for (int i = 0; i < 2; i++)
            {

                if (!PrinterStatus.Equals("0"))
                {
                    PrintLab.PTK_CloseConnect();
                    MessageBox.Show("打印机未就绪，当前错误报告：" + Status_Explain(PrinterStatus));

                    return;
                }

                /*清空缓存*/
                result_printing = PrintLab.PTK_ClearBuffer();
                if (result_printing != 0) { showError("PTK_ClearBuffer", result_printing); return; }

                /*读取高频RFID 块数据*/
                //result_printing = PrintLab.PTK_ReadHFLabelData(1, 5, 'N', data, 256); //读取高频RFID块的数据
                /*读取高频RFID UID*/
                result_printing = PrintLab.PTK_ReadHFLabeUID('N', data, 256);
                if (result_printing != 0) { showError("PTK_ReadHFLabelData", result_printing); return; }
                RFIDData = Encoding.Default.GetString(data).Trim('\0');
                Console.WriteLine("RFIDData:" + RFIDData + "\r\n");


                /*清空缓存*/
                result_printing = PrintLab.PTK_ClearBuffer();
                if (result_printing != 0) { showError("PTK_ClearBuffer", result_printing); return; }

                /*设置打印黑度 取值范围 0-20*/
                result_printing = PrintLab.PTK_SetDarkness(10);
                if (result_printing != 0) { showError("PTK_SetDarkness", result_printing); return; }

                /*设置打印速度*/
                result_printing = PrintLab.PTK_SetPrintSpeed(4);
                if (result_printing != 0) { showError("PTK_SetPrintSpeed", result_printing); return; }

                /*设置打印方向*/
                result_printing = PrintLab.PTK_SetDirection('B');
                if (result_printing != 0) { showError("PTK_SetDirection", result_printing); return; }

                /*设置标签高度、间隙及偏移*/
                result_printing = PrintLab.PTK_SetLabelHeight(29 * mm, 24, 0, false);
                if (result_printing != 0) { showError("PTK_SetLabelHeight", result_printing); return; }

                /*设置标签宽度，一定要准确，否则会导致打印内容位置不准确*/
                result_printing = PrintLab.PTK_SetLabelWidth(59 * mm);
                if (result_printing != 0) { showError("PTK_SetLabelWidth", result_printing); return; }

                /*高频（HF） RFID打印设置*/
                result_printing = PrintLab.PTK_SetHFRFID('H', 0, 0);
                if (result_printing != 0) { showError("PTK_SetHFRFID", result_printing); return; }

                /*打印二维码 此示例为QR码 付款码就是这个码*/
                result_printing = PrintLab.PTK_DrawBar2D_QR((uint)(120 + offset_X), (uint)(48 + offset_Y), 0, 0, 0, 3, 4, 1, 8, E_UTF8("设计精湛 ABCD 1234 ^-^ @@ && $$ ￥￥"));
                if (result_printing != 0) { showError("PTK_DrawBar2D_QR", result_printing); return; }

                /*写RFID数据 具体参数请查看文档*/
                result_printing = PrintLab.PTK_RWHFLabel('W', 4, 8, "41414141395542687474703A2F2F7777772E62616964752E636F6D3F3D344544", false);
                if (result_printing != 0) { showError("PTK_RWHFLabel", result_printing); return; }

                result_printing = PrintLab.PTK_PrintLabelFeedback(status, 8);
                if (result_printing != 0) { showError("PTK_PrintLabelFeedback", result_printing); return; }

                PrinterStatus = int.Parse(Encoding.Default.GetString(status).Trim('\0').Replace("W1", "")) + "";

            }




            /*断开打印机连接*/
            PrintLab.PTK_CloseConnect();
            MessageBox.Show("执行成功！\r\n");
        }

        private void button1_Click_1(object sender, EventArgs e)
        {
            int result = 0;
            var message = "";
            byte[] data = new byte[1024];
            var PrinterInfo = "";
            /*函数返回值*/
            int result_printing = 0;

            /*连接打印机*/
            result = PrintLab.PTK_Connect_Timer(IPAddress, port, 2);
            if (result != 0)
            {
                result = getErrorInformation(result, out message);
                MessageBox.Show(message);
                return;
            }

            /*清空缓存*/
            result_printing = PrintLab.PTK_ClearBuffer();
            if (result_printing != 0) { showError("PTK_ClearBuffer", result_printing); return; }

            // 获取标签打印信息
            result_printing = PrintLab.PTK_GetLabelPrintInfo(E_UTF8("1,2,3,4,5,6,7,8"), data);
            if (result_printing != 0) { showError("PTK_GetLabelPrintInfo", result_printing); return; }


            /*断开打印机连接*/
            PrintLab.PTK_CloseConnect();
            PrinterInfo = Encoding.Default.GetString(data).Trim('\0');
            MessageBox.Show("获取到信息为：" + PrinterInfo);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            int result = 0;
            var message = "";
            /*连接打印机*/
            result = PrintLab.PTK_Connect_Timer(IPAddress, port, 2);
            if (result != 0)
            {
                result = getErrorInformation(result, out message);
                MessageBox.Show(message);
                return;
            }

            /*函数返回值*/
            int result_printing = 0;
            /*横坐标偏移,设置标签整体横向移动位置*/
            int offset_X = 0;

            /*纵坐标偏移，设置标签整体纵向移动位置*/
            int offset_Y = 0;

            /*获取打印机状态*/
            int[] status_Net = new int[4];
            String PrinterStatus1 = "";
            result_printing = PrintLab.PTK_FeedBack();
            if (result_printing != 0) { showError("PTK_FeedBack", result_printing); return; }

            result_printing = PrintLab.PTK_ReadData(status_Net, 48);
            if (result_printing != 0) { showError("PTK_ReadData", result_printing); return; }

            PrinterStatus1 = status_Net[0] + "";

            /*断开打印机连接*/
            PrintLab.PTK_CloseConnect();


            MessageBox.Show("当前打印机状态：" + Status1_Explain(PrinterStatus1));
        }

        private String Status1_Explain(String PrinterStatus1)
        {
            var status_t = int.Parse(PrinterStatus1.Replace("W10", ""));
            var status1 = "";
            switch (status_t)
            {
                case 0: status1 = "无错误"; break;
                case 1: status1 = "语法错误"; break;
                case 4: status1 = "正在打印中"; break;
                case 82: status1 = "碳带检测出错"; break;
                case 83: status1 = "标签检测出错"; break;
                case 86: status1 = "切刀检测出错"; break;
                case 87: status1 = "打印头未关闭"; break;
                case 88: status1 = "暂停状态"; break;
                case 108: status1 = "设置RFID写数据的方式和内容区域执行失败，输入参数错误"; break;
                case 109: status1 = "RFID标签写入数据失败，已达到重试次数"; break;
                case 110: status1 = "写入RFID数据失败，但未超过重试次数"; break;
                case 111: status1 = "RFID标签校准失败"; break;
                case 112: status1 = "设置RFID读取数据的方式和内容区域执行失败，输入参数错误"; break;
                case 116: status1 = "读取RFID标签数据失败"; break;

                default: status1 = "未知错误"; break;
            }

            return status1;



        }

        private void NetForm_Load(object sender, EventArgs e)
        {

        }
    }
}
